Javascript 将变量的值发送到其他页面 side\u bar\u html+=”地址:“+place.neighborary+”距离:“+google.maps.geometry.spherical.computedDistanceBeween(centralallocation,place.geometry.location)。toFixed(2)+”米

Javascript 将变量的值发送到其他页面 side\u bar\u html+=”地址:“+place.neighborary+”距离:“+google.maps.geometry.spherical.computedDistanceBeween(centralallocation,place.geometry.location)。toFixed(2)+”米,javascript,Javascript,我在变量place.geometry.location.toUrlValue(6)中有lat和long的值,我想发送keyplace.geometry.location.toUrlValue(6)的值,而不是静态的lat-long-in-key,即key=40.68509,-73.84357(上图)。我已经试过了,但是出现了一些语法错误。 请告诉我如何将key的值作为place.geometry.location.toUrlValue(6)发送到explore-map2.jsp页面。您可以使用e

我在变量
place.geometry.location.toUrlValue(6)
中有lat和long的值,我想发送key
place.geometry.location.toUrlValue(6)
的值,而不是静态的lat-long-in-key,即
key=40.68509,-73.84357
(上图)。我已经试过了,但是出现了一些语法错误。
请告诉我如何将key的值作为
place.geometry.location.toUrlValue(6)
发送到
explore-map2.jsp
页面。

您可以使用encodeURIComponent()函数清理key=40.68509,-73.84357

例如:

explore-map2.jsp?key=encodeURIComponent(“40.68509,-73.84357”)

side_bar_html += "<a href='javascript:google.maps.event.trigger(gmarkers["+(gmarkers.length-1)+"],\"click\");'>" + place.name + "</br></a></br> Address   :  " + place.vicinity +"</br>Distance : " + google.maps.geometry.spherical.computeDistanceBetween(centralLocation, place.geometry.location).toFixed(2) + " meters</br></br><input type= button OnClick='window.location.href = \"explore-map2.jsp?key=40.68509,-73.84357\"'; value = Locate&nbsp;&nbsp;Direction><br/></br/>"