javascript - Google map 引擎 - 在 InfoWindow 上显示路线

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

我对 Google map 开发非常陌生,需要您的帮助。我正在使用 Google map 引擎通过 CSV 文件加载数据,这有助于自动对地址进行地理编码。创建新图层并将其填充到 map 上后,我在 map 应用程序(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>

最佳答案

如果您使用 Maps Engine 图层来渲染数据,则信息窗口将根据您在 Maps Engine 中的图层设置进行渲染。您可以使用普通的旧链接为用户提供指示(还有好处,在移动设备上它将在 native 应用程序中打开)。

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

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

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

关于javascript - Google map 引擎 - 在 InfoWindow 上显示路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24943576/

相关文章:

javascript - 当我发出新请求时,Ajax http 请求将以前的图像加载到轮播中

javascript - Uncaught ReferenceError : latLng is not defined

android - Flutter Application "won' t 在没有 Google Play 服务的情况下运行”

javascript - 如何删除标记 googlemap $.getjson

javascript - 如何在谷歌地图的彩色多边形上显示街道编号?

api - Google Maps API 3 referrerNotAllowedMapError

javascript - 如何将 div 放在 p 的特定行上?

javascript - HTML5 数据库 API : Synchronous request

javascript - Summernote通过laravel中传递的参数设置文本

javascript - 谷歌地图标记 API 标记的标题