1
我似乎无法使我的地图中的折线显示。我使用setPath并提取变量中的位置点:points。我想要各种多段线在地图上显示。任何建议将不胜感激:)谢谢!谷歌地图API显示折线
var markers = [];
var iterator = 0;
var map;
var mapCenter=new google.maps.LatLng(24.804188,54.862747);
var points = [
['Airport', 24.433241, 54.651096, 12, '#airport'],
['Marine Mall', 24.475968, 54.320953, 11, '#marinemall'],
['Farrari World', 24.481739, 54.606426, 10, '#'],
['Atlantis', 25.1299, 55.117924, 10, '#'],
['Dubai Mall', 25.197126, 55.279092, 10, '#'],
['Burj Khalifa', 25.197097, 55.274144, 10, '#'],
['Burj Al Arab', 25.141167, 55.185472, 10, '#'],
['Water Park', 25.134358, 55.120317, 10, '#']
];
function initialize() {
var styles = [
{
featureType: 'all',
elementType: 'label',
stylers: [
{ visibility:"off" }
]
}
];
var mapOptions = {
center: mapCenter,
zoom:10,
mapTypeId:google.maps.MapTypeId.HYBRID
};
map=new google.maps.Map(document.getElementById("map-canvas"),mapOptions);
map.setOptions({styles:styles});
setPath(map, points);
}
function setPath(map, locations){
for (var i = 0; i < locations.length; i++) {
var place = locations[i];
var myLatLng = new google.maps.LatLng(place[1], place[2]);
var line = new google.maps.Polyline({
map: map,
geodesic: true,
path:myLatLng,
strokeColor:"#ED5552",
strokeOpacity:1,
strokeWeight:2
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
非常感谢您的帮助!有效! – christie
欢迎!很高兴知道 – Blu