2012-08-03 131 views
0

我有两个折线图绘制在谷歌地图api v3方向服务。偏移谷歌地图DirectionsService折线

我的问题是,他们在地图的一部分重叠,一个覆盖其他人。我希望总共绘制6条线路,这些线路是我所在城市的公交线路。所有路线都会回到城市的同一区域,但将它们区分开来是非常困难的。

有没有办法稍微偏移每一行?

function busRoute2(source,destination){ 
     // show route between the points 
     directionsService = new google.maps.DirectionsService(); 
     directionsDisplay = new google.maps.DirectionsRenderer(
     { 
      suppressMarkers: true, 
      suppressInfoWindows: true, 
      polylineOptions: { strokeColor: '#000000', strokeOpacity: 0.5 } 
     }); 
     directionsDisplay.setMap(map); 
     var request = { 
      origin:source, 
      destination:destination, 
      travelMode: google.maps.DirectionsTravelMode.DRIVING 
     }; 
     directionsService.route(request, function(response, status) 
     { 
      if (status == google.maps.DirectionsStatus.OK) 
      { 
       directionsDisplay.setDirections(response); 

      } 
     }); 

} 

回答

0

继承人的工作代码(很基本的)polyLine offset map animated注:“偏移”属性的图标是百分比沿线图标的偏移。 您需要操纵图标的相对“路径”坐标(SVG格式)(在您的情况下为一行)本身,以便将它从行中偏移

0

忘掉我的建议。我试图创建一个重复图标(2像素点),从polyLine偏移4个像素。它看起来非常恶心,并且滞后于浏览器。

我将不得不创建一个函数,根据角度dLat,dLng和缩放比例在加载时编辑折线的坐标。

由于您希望您的标记(停靠站,巴士)和线路位于朝一个方向而另一个方向返回的一侧。你也不想如果有人想帮助这个在[email protected]给我发电子邮件

+0

感谢您的答复掩盖了地图

上的路名 – 2012-08-08 13:46:27