css - Styling GeoJSON polygons loaded via a URL in javascript, MapBox -
below little bit of code produces 2 polygon layers displayed gray, semitransparent shaded polygons default:
var overlays = { seniorsnorm: l.mapbox.featurelayer().loadurl('data/seniorsage65+.geojson'), aqiriskzones: l.mapbox.featurelayer().loadurl('data/aqizones.geojson'), }; would possible assign fill color, opacity, etc? have tried , can't quite there. thank in advance.
the signature l.mapbox.featurelayer follows:
l.mapbox.featurelayer(id|url|geojson, options)
https://www.mapbox.com/mapbox.js/api/v2.2.4/l-mapbox-featurelayer/#section-l-mapbox-featurelayer
which means can pass url directly first parameter don't need use loadurl. can use if later on want reload or load url. set style on layer's features can use setstyle method described in documentation l.featuregroup l.mapbox.featurelayer extended from:
sets given path options each layer of group has setstyle method.
http://leafletjs.com/reference.html#featuregroup-setstyle
which boil down this:
l.mapbox.featurelayer('data/seniorsage65+.geojson').setstyle({fillcolor: 'red'}) the style object supports path options decribed in link:
Comments
Post a Comment