我有这样的要求,我需要在悉尼、墨尔本和阿德莱德之间划一条线,悉尼和阿德莱德之间的界线应该是深色,墨尔本和阿德莱德之间的界线应该是打火机。
在当前API中是否可以在单个对象中提供此功能:
new google.maps.Polyline({
});来实现这个功能?
发布于 2015-12-09 22:54:36
一个选项是为每一行创建google.maps.Polyline对象,下面是简单折线页修改后的示例
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5,
center: {lat: -32.9340105, lng: 128.2698231},
mapTypeId: google.maps.MapTypeId.TERRAIN
});
var flightPlanCoordinates = [
{lat: -33.877024, lng: 151.227963},
{lat: -37.816567, lng: 144.961489},
{lat: -34.930054, lng: 138.593065}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates.slice(0,2),
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2,
map: map
});
var flightPath2 = new google.maps.Polyline({
path: flightPlanCoordinates.slice(1,3),
geodesic: true,
strokeColor: '#FFCC00',
strokeOpacity: 1.0,
strokeWeight: 2,
map: map
});
}html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
} <div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script>
发布于 2015-12-06 05:04:01
单个polyline具有一组属性。对于每个唯一的属性集,您可以使用一个google.maps.Polyline来完成这个任务,因此在您的示例中,可以使用两个多边形。
https://stackoverflow.com/questions/34114183
复制相似问题