google映射api方向javascript变量

google maps api directions javascript variables

本文关键字:javascript 变量 方向 api 映射 google      更新时间:2023-09-26

由于地图上标记的信息窗口,我在加载地图时遇到错误。在信息窗口中,我想要一个方向的链接,所以我打算在URL中传递目的地坐标。但它不喜欢我使用的语法,尽管我没有收到任何错误。

var contentString2 = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h3 id="firstHeading" class="firstHeading"><a name="FLOSSMOOR STATION RESTAURANT & BREWERY"></A><strong><A HREF="redirect.cfm?address=http://www.flossmoorstation.com" TARGET="_blank">FLOSSMOOR STATION RESTAURANT & BREWERY</A></strong></h3>'+
'<div id="bodyContent">'+
'<p><a href="index.cfm?in='document.write(initialLocation);'+'&'+'document.write(myLatlng2);'+'">Directions</a></p>'+
'</div>'+
'</div>';

有了这个信息窗口的变量,我得到了一个可爱的灰色屏幕,没有加载地图,还有更好的方法来制作信息窗口div吗?谢谢

如果myLatlng2是Google Maps API v3中的LatLng对象,那么您可能会在URL构造中对其进行最小的更改:

document.write(myLatlng2)

更像这样的东西:

document.write(myLatlng2.toUrlValue())