【问题标题】:Google Maps Engine - Display Directions on InfoWindowGoogle Maps Engine - 在 InfoWindow 上显示路线
【发布时间】:2014-07-24 20:42:08
【问题描述】:

我是 Google Maps Dev 的新手,需要您的帮助。我正在使用谷歌地图引擎通过 CSV 文件加载数据,这有助于自动对地址进行地理编码。创建新图层并在地图上填充它们后,我在我的地图应用程序(JSv3 API)上调用 Map 和 LayerI.D。当我单击标记时会弹出信息窗口,并且我希望在信息窗口上有方向(功能)链接。有没有一种方法可以像我们在一般的谷歌地图搜索上一样在信息窗口上提供方向服务。 我的代码如下所示。

<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>

【问题讨论】:

  • 您有什么尝试过的吗? 有没有办法
  • @Dr.Molle 我尝试过使用 APIv3 Directions 服务,但它出现在地图上。我希望在信息窗口上有路线链接。
  • @geocodezip 我正在使用 APIv3,教程显示这些方法已被 Google 拒绝。有没有其他方法可以实现这一点。
  • 有很多方法可以实现它。你看过我的例子吗(不是 Mike 的教程)?

标签: javascript google-maps google-maps-api-3 google-maps-engine


【解决方案1】:

如果您使用 Maps Engine 图层来呈现数据,则信息窗口会根据您在 Maps Engine 中的图层设置来呈现。您可以使用普通的旧链接为用户提供路线(和奖励,在移动设备上它会在本机应用程序中打开)。

这样的 URL 将提供从“当前位置”(地图将解释为用户的位置)到提供的纬度/经度的路线:https://www.google.com/maps/dir/Current+Location/43.12345,-76.12345

Maps Engine 的信息窗口字段也可能有帮助:https://support.google.com/mapsengine/answer/2984965?hl=en

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

【讨论】:

    猜你喜欢
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    • 2015-08-19
    • 1970-01-01
    • 2013-09-26
    • 2020-02-17
    • 2019-07-18
    相关资源
    最近更新 更多