Google Maps - google.maps.geometry.spherical.computeDistanceBetween () returns NaN

0

I have several Bookmarks on the map and when I select any of the Bookmarks, I would like you to calculate the distance between the selected Bookmark and the rest that are on the map. All markers come from a database.

When I use computeDistanceBetween() , I can only calculate the distance to another marker specified by me in the code, using google.maps.LatLng() .

Example:

WhencalculatingthedistancefromtheselectedMarker(whichcanbeanyofthemap)toallothermarkersonthemap,usingavariablethatcontainsallLatLng()ofallmarkers,thefunctioncomputeDistanceBetween()returnsvalueNaN,seenhere:

HowcanIreceivetheselectedMarkerdistancecalculationforallothersatthesametime?

Hereisthecodewhenselectingoneofthebookmarks:

google.maps.event.addListener(marker,'dblclick',(function(marker,i){returnfunction(){infoWindow.setContent(infoWindowContent[i][0]);infoWindow.open(map,marker);circleRadius=newgoogle.maps.Circle(circle);circleRadius.bindTo('center',marker,'position');//document.getElementById('over_map_ocorrencias').innerHTML=toMarkers[i];//document.getElementById('over_map_ocorrencias').innerHTML=infoWindowContent[i];closeMarkers=google.maps.geometry.spherical.computeDistanceBetween(newgoogle.maps.LatLng(allMarkers[i][0],allMarkers[i][1]),newgoogle.maps.LatLng(toMarkers[0],toMarkers[1]));////40.2431539,-7.201015--Meimoadocument.getElementById('over_map_ocorrencias').innerHTML=closeMarkers/1000+'<b>KMdedistância</b>';}})(marker,i));

ThevariablesallMarkersandtoMarkersareequal,theyhavetheLatLngvaluesofallthemarkers,whereintheposition[0]isthevalueofLatandtheposition[1]thevalueofLng.

" over_map_ocorrencias " is the name of Div where the distance value appears.

    
asked by anonymous 27.09.2018 / 14:06

0 answers