-1
不能完全弄清楚我做錯了什麼......我可以得到「標記」顯示,只有標準的橙色/紅色標記,但我試圖讓「星巴克」標記出現在自定義圖像中。我的地圖出現,但不是第二個標記。我在哪裏滑倒? 這裏是我的代碼:嘗試(和失敗)使用谷歌地圖標記的自定義圖像
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(33.7442357,-118.015271);
var image = 'images/coffee.png';
var mapOptions = {
zoom: 17,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Business Name'
});
var starbucks = new google.maps.Marker({
position: new google.maps.LatLng(33.744236,-118.015271),
map: map,
icon: image,
title: 'Starbucks'
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
什麼是「圖像」?它是否存在於你的服務器/機器上的相對路徑上? – geocodezip
[這適用於我](http://www.geocodezip.com/v3_SO_simpleMap_starbucksIcon.html)(您的代碼以及內嵌圖標) – geocodezip