小编Abd*_*ara的帖子

如何使用多色折线绘制谷歌地图航点

嗨我尝试在谷歌地图上绘制带方向航点的折线.

我尝试过类似的东西. 我的平局 我的平局 我想用这样的不同颜色绘制路线.

谷歌地图方向示例ss 谷歌地图方向示例ss

我写了这个示例代码.

 function initMap() {
    var directionsService = new google.maps.DirectionsService;
    var directionsDisplay = new google.maps.DirectionsRenderer;
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 6,
      center: {lat: 41.85, lng: -87.65}
    });
    directionsDisplay.setMap(map);
    calculateAndDisplayRoute(directionsService, directionsDisplay);
  }

  function calculateAndDisplayRoute(directionsService, directionsDisplay) {
    var waypts = [
          {
            location: '41.062317, 28.899756',
            stopover: true
          },
          {
            location: '41.062276, 28.898866',
            stopover: true
          },
          {
            location: '41.061993, 28.8982',
            stopover: true
          }
        ];
    directionsService.route({
      origin: {lat: 41.063328, lng:28.901215},
      destination:{lat: 41.060756, lng:28.900046},
      waypoints: waypts,
      optimizeWaypoints: true,
      travelMode: …
Run Code Online (Sandbox Code Playgroud)

browser google-maps directions google-polyline

2
推荐指数
1
解决办法
6905
查看次数