【问题标题】:How to Plot Route on Google Maps如何在谷歌地图上绘制路线
【发布时间】:2016-06-16 19:46:43
【问题描述】:

我正在使用下面的代码来绘制路线

function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: 0, lng: -180},
mapTypeId: google.maps.MapTypeId.TERRAIN
});

var flightPlanCoordinates = [
{lat: 37.772, lng: -122.214},
{lat: 21.291, lng: -157.821},
{lat: -18.142, lng: 178.431},
{lat: -27.467, lng: 153.027}
];
 var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});

flightPath.setMap(map);
}

使用折线仅给出直线是否有任何其他方法可以像示例路线图像中那样绘制路线。 我试过了,但没有得到任何这样的方法

【问题讨论】:

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


【解决方案1】:

看这里:
http://www.geocodezip.com/v3_polyline_example_arc.html
和这里:
http://www.geocodezip.com/v3_polyline_example_rhumb.html

要做到这一点,您可能希望在某种正弦曲线上抽象路径,使其更弯曲且更具视觉吸引力。看看下面的问题,有很多深入的答案。

Curved line between two near points in google maps

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 2011-06-07
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多