0

In the past I was able to create a layer and specify interactivity and which fields would be returned on featuerOver etc. The code below worked in the past but now returns and error of "Interactivity is read-only in NamedMaps"

cartodb.createLayer(map, 'link to my viz')
.addTo(map)
.on('done', function(layer) {                  
  layer.setInteraction(true);
  layer.getSubLayer(0).setInteractivity("cartodb_id,_name")
  layer
    .on('featureOver', function(e, latlng, pos, data) {
      console.log(data);
    })
}).on('error', function(err) {
  console.log("some error occurred: " + err);
});  
  • 1
    are the data tables that your viz.json file pointing to set to private? named maps refer to public maps made from private data. – Andy Eschbacher Apr 21 '15 at 21:49
  • That was the problem.. If you add an answer I can select it as correct – jotamon Apr 21 '15 at 21:51
2

Like I said in the comments above, the error referring to named maps means that the data tables that the viz.json points to are set to private. In order to configure them you have to set interactivity using the CartoDB Editor, do an authenticated call to the server creating the map, or set them to public or public with link and do the JavaScript that was quoted above.

For more info on named maps, checkout this tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.