我有一个谷歌地图,它使用下面的代码显示多个标记。我想将其中一些分组并使用不同的图标,如果可能的话,我想设置类似
['Bondi Beach', -33.890542, 151.274856 type="restaurant"],
['Bondi RD', -33.89457, 151.26826 type="hotel"],
等等,然后根据它的类型显示不同的图标。
var markers1 = [
['Bondi Beach', -33.890542, 151.274856],
['Bondi RD', -33.89457, 151.26826],
['Wellington St', -33.89136, 151.26474],
['Bondi RD', -33.89457, 151.26826],
['Belleve Hill', -33.88673, 151.25839],
['Belleve RD', -33.88424, 151.25427],
['Blair St', -33.88509, 151.27058],
['Wollahra', -33.88951, 151.24500],
['Double Bay', -33.87783, 151.23985],
['Kings Cross', -33.87498, 151.21788],
['Shaw St', -33.88110, 151.27088],
['Coogee Beach', -33.923036, 151.259052],
['Cronulla Beach', -34.028249, 151.157507],
['Manly Beach', -33.80010128657071, 151.28747820854187],
['West of sydney', -33.87270, 151.15746],
['Maroubra Beach', -33.950198, 151.259302]
];
function initializehotell() {
alert("init hotell");
var latlng = new google.maps.LatLng(-33.92, 151.25);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
var map1 = new google.maps.Map(document.getElementById("map_canvashotell"),myOptions);
image = new google.maps.MarkerImage("http://www.mydomain.com/images/googlemap/info.png",new google.maps.Size(32, 45));
shadowi = new google.maps.MarkerImage("http://www.mydomain.com/images/googlemap/shadow.png",new google.maps.Size(51, 37));
var infowindow = new google.maps.InfoWindow(), marker, i;
for (i = 0; i < markers1.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(markers1[i][1], markers1[i][2]),
map: map1,
shadow: shadowi,
icon: image
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(markers1[i][0]);
infowindow.open(map1, marker);
}
})(marker, i));
}
}
我想我必须在循环位置更改它: new google.maps.LatLng(markers1[i][1], markers1[i][2]) 不知何故,但我不确定如何。因此,任何输入都非常感谢,谢谢。