Javascript 在谷歌地图上绘制曲线
我试图在谷歌地图上画曲线。 当我搜索它时,我发现有一个名为“测地线”的属性被设置为true以启用曲线的绘制,但当我使用它时,它绘制了一条非曲线的线。 这就是我所做的。 我只是把测地线设为真Javascript 在谷歌地图上绘制曲线,javascript,google-maps,Javascript,Google Maps,我试图在谷歌地图上画曲线。 当我搜索它时,我发现有一个名为“测地线”的属性被设置为true以启用曲线的绘制,但当我使用它时,它绘制了一条非曲线的线。 这就是我所做的。 我只是把测地线设为真 var flightPath = new google.maps.Polyline({ path: flightPlanCoordinates, geodesic: true, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 2 }); 这
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
这是完整的代码
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple Polylines</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(0, -180),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
map.setCenter(new google.maps.LatLng(45.56117947133065,-122.5868225097656));
var flightPlanCoordinates = [
new google.maps.LatLng(45.56117947133065,-122.5868225097656),
new google.maps.LatLng(45.493833740092185,-122.6348876953125)
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
参考的小提琴使用GmapsCubicBezier绘制曲线。难道没有一个解决方案可以让它以小比例出现吗?为什么你不能像你贴的小提琴那样使用GmapsCubicBezier?我没有在小提琴中使用GmapsCubicBezier,或者可能我不理解你。这不是我的一个例子,也不是我的一个例子的副本,它使用GmapsCubicBezier绘制曲线多段线。