Show a moving marker on the map

后端 未结 3 1993
星月不相逢
星月不相逢 2020-12-28 11:24

I am trying to make a marker move(not disappear and appear again) on the map as a vehicle moves on the road.

I have two values of latLng and I want

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 11:59

    Why not keep the existing Marker/ MarkerImage and call setPosition() to move it, either on a timer or as the position changes?

    Deleting it & recreating it is what causes it to flash/ flicker and eventually crash. If you keep the same instance but just move it, you should do much better.

    See: Marker.setPosition()

    https://developers.google.com/maps/documentation/javascript/reference#Marker

提交回复
热议问题