0
votes

I have a MapBox map that has pins on it created via the MapBox website.

I'm calling this map with those push pins on my site.

I cannot for the life of me, find any relevant code to work off to do 2 things:

1) I need to modify the GeoJSON data of the pre-made points to add URLs to them (to do something like this: https://www.mapbox.com/mapbox.js/example/v1.0.0/markers-as-links/ ). How can I access these existing objects in JS? THe only code examples I see have you creating the points/GeoJSON data right in code.

2) Toggle layers I add to this map via TileMill programmatically. I have a highlight layer I'd like to make a UI element on my HTML page to toggle on and off.

Thank you.

EDIT:

Not doing anything crazy to call the map.

var map = L.mapbox.map('map', 'aam.map-ryzkcons');

Then I set some coordinates and a zoom level.

map.setView([34.89, -87.31], 6);

And turn it all on

map.markerLayer.on('click', function(e) {
map.panTo(e.layer.getLatLng()); 
});

The map aam.map-ryzkcons was made in the web UI of mapbox. It also has some layers I uploaded via TileMill. I'd like to figure out how to switch any of those layers on and off in code. I also want to access the marker and add URL tags to them to make them clickable - as I dont see a way to do that in the web UI. The only examples I can find of doing this, have you creating the markers in code beforehand, not in the web UI like I have done. I'd like to keep it that way, so maintainers can just go to mapbox.com to add a marker.

1
It would be helpful to see what the code that you're working on is in specific - if you need to post a private ticket, there's a MapBox support forum support.mapbox.com โ€“ tmcw
sorry about that. post updated. โ€“ Sputnikk23

1 Answers

1
votes

Toggle layers I add to this map via TileMill programmatically. I have a highlight layer I'd like to make a UI element on my HTML page to toggle on and off.

See the layers control example.

How can I access these existing objects in JS?

Wait for the ready event, and then use getGeoJSON to get the data, or eachLayer to iterate over layers. Use the API documentation as a reference.