我想在Google地圖上使用我的自定義圖標,並在代碼上添加了圖標網址。但它仍然沒有反映在地圖上。任何人都可以建議,我在這裏失蹤。添加圖標網址「http://google-maps-icons.googlecode.com/files/sailboat-tourism.png」後,爲什麼圖標不會更改。如何更改Google地圖標記上的圖標
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var markers = [
{
"title": 'This is title',
"lat": '-37.801578',
"lng": '145.060508',
"icon": 'http://google-maps-icons.googlecode.com/files/sailboat-tourism.png',
"description": 'Vikash Rathee. <strong> This is test Description</strong> <br/><a href="http://www.pricingindia.in/pincode.aspx">Pin Code by
City</a>'
}
];
</script>
<script type="text/javascript">
window.onload = function() {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 10,
flat: true,
styles: [ { "stylers": [ { "hue": "#4bd6bf" }, { "gamma": "1.58" } ] } ],
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
</script>
<div id="dvMap" style="width: 100%; height: 100%">
</div>
EdenSource,沒有工作。你可以在小提琴或cssdeck上發佈完整的代碼或演示嗎? – Vicky
圖標:標記[i] [3],可能是錯誤的。替換爲「圖標」:'http://google-maps-icons.googlecode.com/files/sailboat-tourism.png', – EdenSource