google maps - Get LatLng given a point -
i referencing locations on google maps (by loading json data using ajax) , store points in array, link markers each other , store polylines in array well.
now attempting filter markers (given name), retrieve corresponding marker (or point) previous list, , perform loop on polylines ones have latter point start or end. problem polyline coordinates of start , end using function polyline.getpath().getat(indiceloop);
, , need compare point's coordinate.
so, there way coordinates latlng given created point?
thanks lot !
assume google.maps.marker ("marker") , google.maps.polyline ("polyline"). not tested.
if (google.maps.geometry.spherical.computedistancebetween(marker.getposition(),polyline.getpath().getat(0)) < 0.1) { // marker @ start of polyline alert("marker @ start"); } else if (google.maps.geometry.spherical.computedistancebetween(marker.getposition(),polyline.getpath().getat(polyline.getpath().getlength()-1)) < 0.1) { // marker @ end of polyline alert("marker @ end"); }
Comments
Post a Comment