1 回答
TA贡献1936条经验 获得超7个赞
您可以创建一个包含坐标(经度和纬度)的对象数组。使用forEach循环数组通,并作出标记。
var listOfLocations = [
{lat: 18.906286,lng: 19.102439}, //Somewhere in Africa
{lat: 8.331083,lng: 105.549002}, //Somewhere near Vietnam
{lat: -27.440040,lng: 135.067341}, //Somewhere in Australia
{lat: -14.338904,lng: -51.507365}, //Somewhere in Brazil
];
listOfLocations.forEach(function(o) { //Loop thru the array
var marker = new google.maps.Marker({ //Make the marker and add to the map
position: o,
map: map,
icon: markerImage //Set image
});
})
注意:无需new google.maps.LatLng根据Google Map Marker Doc制作对象
添加回答
举报
