geojson - Adding custom markers to the mapbox gl -
i add custom marker map. using mapbox gl script.
the documentation found related topic 1 https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/.
i tried customize given example , managed add marker , modify little changing size, since don't understand parameters, don't know how add own marker. there documentation more detailed?
here code:
<script> mapboxgl.accesstoken = 'pk.eyj1ijoiywl3yxrrbyisimeioijjaxbncni5ejgwmde0dmjucta5adrrb2wzin0.b2zm8wb9m_qis1tneswslg'; var map = new mapboxgl.map({ container: 'map', // container id style: 'mapbox://styles/aiwatko/cipo0wkip002ddfm1tp395va4', //stylesheet location center: [7.449932,46.948856], // starting position zoom: 14.3, // starting zoom interactive: true }); map.on('load', function () { map.addsource("markers", { "type": "geojson", "data": { "type": "featurecollection", "features": [{ "type": "feature", "geometry": { "type": "point", "coordinates": [7.4368330, 46.9516040] }, "properties": { "title": "duotones", "marker-symbol": "marker", } }] } }); map.addlayer({ "id": "markers", "type": "symbol", "source": "markers", "layout": { "icon-image": "{marker-symbol}-15", "icon-size": 3 } }); }); </script>
thanks in advance!
oktawia
there 2 ways customize markers in mapbox.
raster markers in mapbox
see link on mapbox.com custom marker icons. example shows how use .png marker.
svg markers in mapbox
you pretty close modifying icons
, take time familiarize parameters.
the icon-image
may harder 1 understand. takes property "marker-symbol": "marker"
geojson, , "icon-image": "{marker-symbol}-15"
, create final result of marker-15
.
this brings further question: where/how markers defined?!?
the markers come mapbox , called maki icons. can change "marker-symbol"
aquarium
or cafe
see results.
from mapbox gl style reference
icon-size
— scale factor icon. 1 original size, 3 triples size.icon-image
— string {tokens} replaced, referencing data property pull from.
Comments
Post a Comment