i trying zoom , add markers html openlayers map, far hardcoded lat , long pulled json result. in first place drop marker @ location , using lat , lng create function avoid harcoding , being able drop marker json entry.
here code far, location zoomed location cant find how drop marker? thanks!
var map = new ol.map({ layers: [ new ol.layer.tile({ source: new ol.source.osm()}) ], view: new ol.view({ center: ol.proj.fromlonlat([103.835471, 1.303371]), zoom: 6 }), target: 'map' });
here basic steps want follow:
- create vector layer (
ol.layer.vector
) vector source (ol.source.vector
) - include layer in map's "layers" array
- create feature (
ol.feature
) desired geometry - call
addfeature()
on vector source add feature layer
make sure transform coordinates geometry if lat/lon.
the following may helpful:
Comments
Post a Comment