javascript - google maps api add a LatLng to the start of a polyline -
i using google maps api draw gps track on map. using polyline overlay. far, works fine, dynamically add , remove points both sides of polyline.
for removing points , adding points end of polyline know can use
google.maps.polyline.getpath().removeat(index);
and
google.maps.polyline.getpath().push(latlng);
is there function add points start of polyline easily? (similar how 1 use array.unshift(value)
adding element start of array)
the path of polyline mvcarray class has array methods. https://developers.google.com/maps/documentation/javascript/3.exp/reference#mvcarray
therefore use insertat() insert new point @ index 0.
insertat(0, item)
Comments
Post a Comment