How to move a marker in an OpenLayers.Layer.Markers layer?

后端 未结 3 915
醉话见心
醉话见心 2021-01-20 21:28

How can I programmatically move an existing marker on an OpenLayers.Layer.Markers layer? I can\'t seem to find a proper way.

Is this supported at all? O

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 22:28

    if you have lon/lat for the new point then marker could be moved as:

    var newLonLat = new OpenLayers.LonLat(lon, lat);
    var newPx = map.getLayerPxFromLonLat(newLonLat);
    myMarker.moveTo(newPx);
    

提交回复
热议问题