lundi 29 décembre 2014

How to use cartodb.js to create layer - not just tilelayer - from named map layergroupid


This gis.stackexchange question asks how a layer can be displayed after getting a layergroupid after initializing a named map.


I don't have enough reputation to ask a follow-up comment to javisantana's response. It reads in part:



Why didn't you use cartodb.js to get that layergroup? if you are going to use
cartodb.js it's better to use it to get that layergroup


My question is: how do you use cartodb.js to get that layergroupid? I can do it just fine using the instructions on the Maps API page and can also successfully create a leaflet tileLayer in a fashion similar to that which javisantana's suggests. However, I would love to be able to use cartodb.js and then be able to do a bit more than just display a static tileLayer (e.g. replace the named map's template variables at client run time).


It seems like it might be possible to do this calling cartodb.createLayer, but my attempts to provide layermetadata have not been successful. The documentation on the cartodb.js page is a little unclear:



cartodb.createLayer(map, { layermetadata })
Layer metadata is always in the form: { type: 'LAYER_TYPE_NAME', options: {...} }




Aucun commentaire:

Enregistrer un commentaire