如何輕鬆更改圖標的顏色?我只是希望能夠使用Google標準標記將其更改爲不同的顏色?有沒有一種方法可以在var = marker .....中創建標記的地方聲明顏色?更改google地圖標記顏色
<script type="text/javascript">
var map = null;
function initialize() {
var myOptions = {
zoom: 5,
center: new google.maps.LatLng(54.2361100,-4.5480600),
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
var point = new google.maps.LatLng(50.7184100,-3.5339000);
var marker = createMarker(point,'<div style="width:200px"><h2>text</h2><\/div>')
var point = new google.maps.LatLng(50.9097000,-1.4043500);
var marker = createMarker(point,'<div style="width:200px"><h2>text</h2><\/div>')
}
var infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
function createMarker(latlng, html) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
map: map,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map_canvas" style="width: 535px; height: 500px"></div>
http://stackoverflow.com/questions/2472957/how-can-i-change-the-color-of-a-google-maps-marker - 除了這個之外你還需要做什麼嗎? – Knightsy
是的。我無法得到它的工作。我試過在var marker = createMarker之後放置代碼。 ???? – user2208358