javascript - Styling a geoJSON Feature Layer in MapBox -
I'm just starting playing with MapBox and running in a deceptive issue. I am creating a ground floor layer map using this code:
var map = l.mapbox.map ('map', ' gt;'); Var zipLayer = L.mapbox.featureLayer ('data / blah.json'); ZipLayer.addTo (map); ZipLayer.setStyle ({color: 'red'}); The map appears and reflects the geographical position, but this style ignores when I copy the last line in the JS console in my browser, it works fine, although.
What am I missing here? Apart from this, I have tried at least a dozen different ways to include the style in the optionleer () call directly, but nothing has worked, how can I specify the style when I make a feature layer? ?
I'm guessing a bit, because I do not know the mapbox JS very well, but It looks like an async error, oddly, I do not see anything in the MapBox or Litter API about a callback for this function. But, you can directly facilitate GeoJSON (), then I suggest using jQuery (or my XHR library of choice) to get the data:
var Map = l.mapbox.map ('map', '& lt; MapBoxID & gt;'); Var zipper; $ .getJSON ('data / blah.json', function (data) {zipLayer = L.mapbox.featureLayer (data); zipLayer.addTo (map); zipLayer.setStyle ({color: 'red'})}}; Hope this will do the trick.
Comments
Post a Comment