2

I am having issues with toggling map layers with mapbox.js. Using the code from [https://www.mapbox.com/mapbox.js/example/v1.0.0/layers/] it pulls the basic mapbox base maps ex. mapbox.outdoors or mapbox.satellite as toggle layers, but the polygons on the personal map layer does not appear. I know that the map can be pulled by itself, but when I try to add it to a toggling map, the polygons do not appear. I am not sure if it is a problem with the code itself that isn't allowing my personal map to show, or if there is an issue with my mapbox map.

My github repository is https://github.com/beyeraut/mappingmv/blob/gh-pages/attempt.html

Any ideas are welcome!

2
  • Can you explain where you have added the polygons that are not showing up? Are they in Mapbox Studio, TileMill, GeoJSON, etc. Also (remember to issue a new Mapbox Access token after the problem is solved) - anyone can go in and take it as it stands. but it will be fine if you issue a new token.
    – MDHald
    Feb 19, 2016 at 21:19
  • The polygons were made in QGIS and pulled into mapbox classic as a GeoJSON file. And thanks for the advice about the access token! Feb 21, 2016 at 20:49

1 Answer 1

3

Your GeoJSON would be a featureLayer for your map (project) so you would need to add that separately using the loadID method. Adding it as a map would include the featureLayer by default. You can add the features using something like loadID:

var featureLayer = L.mapbox.featureLayer()
    .addTo(map);

// loads markers from the map mapbox.dark on Mapbox,
// if that map has markers
featureLayer.loadID('mapbox.dark');
2
  • Your answer is missing a word before the first period.
    – raphael
    Feb 22, 2016 at 6:05
  • zoops! updated!
    – geografa
    Mar 9, 2016 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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