简体   繁体   English

Google Maps距离/持续时间标记和标签

[英]Google Maps Distance/Duration Markers & Labels

On this screenshot of Google Maps, you can see the Duration of the drive and the distance, for both the main route and the alternative one, and the textual labels for the destination (Knutsford Golf Club). 在此Google Maps屏幕截图中,您可以看到主要路线和备选路线的行驶持续时间和距离,以及目的地的文本标签(纳特福德高尔夫俱乐部)。

在此处输入图片说明

I'm using the Google Maps API and have added the route and alternate route but I'm unable to find anything in the documentation about these distance/duration markers and the textual labels. 我正在使用Google Maps API,并添加了路线和替代路线,但是我在文档中找不到有关这些距离/持续时间标记和文本标签的任何内容。

Are they possible to recreate in any sensible way or are they something for only Google? 它们有可能以任何明智的方式重新创建,还是仅适用于Google?

They are controlled by google by default. 默认情况下,它们由google控制。 When you do a directions request, you can remove the markers by using supressMarkers property 进行路线请求时,可以使用supressMarkers属性删除标记

directionsDisplay = new google.maps.DirectionsRenderer(
  {
      suppressMarkers: true
  });

Reference: Directions Renderer Options 参考: Directions渲染器选项

Directions request does provide with all values for turn by turn navigation. 路线请求确实提供了所有用于转弯导航的值。

Additionally: You can add all the default markers of directionRenderer by yourself on the map, controlling the way in which you want. 另外:您可以在地图上自行添加directionRenderer的所有默认标记,以控制所需的方式。

directionsService = new google.maps.DirectionsService();
directionsService.route(request, function (response, status) {
   directionsDisplay = new google.maps.DirectionsRenderer(
  {
      suppressMarkers: true
  });

All the steps of the direction service can be found in directionsDisplay.directions.routes[0].legs[0].steps which gives the content of info windows and position of the markers as displayed on map. 方向服务的所有步骤都可以在directionsDisplay.directions.routes[0].legs[0].steps ,这些信息提供了信息窗口的内容以及在地图上显示的标记的位置。

You will have multiple routes , if available and multiple legs if there are waypoints present. 您将有多种routes ,如果有的话,多legs是否有存在的航点。

Do a console.log(directionsDisplay) and further explore the result object. 执行console.log(directionsDisplay)并进一步浏览结果对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM