我敢肯定这一定很容易,但我是 Javascript 的新手......
我有以下代码来显示谷歌地图上的点列表:
<script type="text/javascript">
var locations = [
['<b>Customer</b><br>Address', 52.6699927, -0.7274620, 1],
['<b>Leicester</b><br>Unit B, St Margarets Way, Leicester<br>0116 262 7355', 52.646179, -1.14004, 2],
['<b>Nottingham</b><br>Victoria Retail Park, Netherfield, Nottingham<br>0115 940 0811', 52.961685, -1.06394, 3],
['<b>Nuneaton</b><br>Newtown Road Nuneaton Warwickshire<br>02476 642220', 52.5245, -1.46764, 4],
['<b>Peterborough</b><br>Mallory Road, Boongate, Peterborough, Cambridgeshire<br>01733 561357', 52.574116, -.219535, 5],
['<b>Wellingborough</b><br>Victoria Retail Park, Whitworth Way, London Road, Wellingborough<br>01933 276225', 52.289585, -.68429, 6]
];
var map = new google.maps.Map(document.getElementById('map'),
{
zoom: 9,
center: new google.maps.LatLng(52.6699927, -0.7274620),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
);
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
});
google.maps.event.addListener(marker, 'click', (function(marker, i) { return function()
{ infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})
(marker, i)); }
</script>
“位置”列表中的第一个位置是地图的中心,我只想更改此标记的颜色。我知道我可以使用icon
,但不确定如何调整for
循环代码来做到这一点。
你能帮我吗?
提前谢谢了。