谷歌地图引擎-显示方向上的信息窗口

Google Maps Engine - Display Directions on InfoWindow

本文关键字:信息 信息窗 窗口 方向 引擎 显示 谷歌地图      更新时间:2023-09-26

我是非常新的谷歌地图开发,需要你的帮助。我使用谷歌地图引擎通过CSV文件加载数据,这有助于自动对地址进行地理编码。在创建新图层并在地图上填充它们之后,我调用map和LayerI。D在我的地图应用程序(JSv3 API)。当我点击标记时,信息窗口弹出,我希望在信息窗口上有方向(功能)链接。有一种方法,我可以有方向服务的信息窗口,就像我们有一般的谷歌地图搜索。我的代码是这样的:

<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=###############">
</script>
<script type="text/javascript"src="http://maps.googleapis.com/maps/api/js?libraries=visualization&key=##############"></script><script type="text/javascript">``function initialize(){var mapOptions={zoom: 5,center:new google.maps.LatLng(42, -99)};
    map = new google.maps.Map(document.getElementById('map-canvas'),
    mapOptions);
    var mapsLayer = new google.maps.visualization.MapsEngineLayer({
    mapId: '131467379863959',
    layerKey: 'layer_00001',
    map: map,
 suppressInfoWindows: false,
 clickable: true
});
 var mapsLayer2 = new google.maps.visualization.MapsEngineLayer({
 mapId: '13146737986395',
 layerKey: 'layer_00002',
 map: map,
 suppressInfoWindows: false,
 clickable: true});}

 google.maps.event.addDomListener(window, 'load', initialize);
 </script>

如果你使用地图引擎图层来渲染你的数据,那么信息窗口将根据你在地图引擎中的图层设置来渲染。你可以使用一个普通的链接来给用户指示方向(而且,在移动设备上,它会在本地应用程序中打开)。

像这样的URL将提供从"当前位置"(地图将解释为用户的位置)到提供的lat/lng的方向:https://www.google.com/maps/dir/Current+Location/43.12345,-76.12345

地图引擎的infowindow字段可能也有帮助:https://support.google.com/mapsengine/answer/2984965?hl=en

更多关于地图链接的信息在这篇文章中:http://gearside.com/easily-link-to-locations-and-directions-using-the-new-google-maps/