我正在用客戶端提供的位置上的自定義符號做谷歌地圖。粘貼在下面是一個簡化版本。當我在自己的硬盤驅動器中設置標記圖形.png的路徑,並在我自己的瀏覽器中查看地圖時,一切正常。自定義標記出現在正確的位置。谷歌地圖不會從Dropbox中拉出標記符號
但是,當我在Dropbox中設置標記.png的路徑時,標記不會出現在地圖上 - 既沒有或沒有Dropbox添加到文件名的「?dl = 0」後綴。我也嘗試在Google雲端硬盤上保留圖片並從那裏拉出來;那也行不通。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>GoogleMapHawthorne It Works!</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 950px; height: 525px;"></div>
<script type="text/javascript">
// locationsSC = locations in Service, Community Asset layer
var locationsSC = [
['Fish Emergency Services', 45.512388, -122.651950],
['Southeast Community Bike Fix-it Station', 45.512360, -122.634061],
['Southeast Kitchen Share', 45.508305, -122.637014],
['Southeast Tool Library', 45.508312, -122.637690],
['Southeast Uplift Neighborhood Coalition', 45.513445, -122.627480]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: new google.maps.LatLng(45.510000, -122.630930),
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
// adding Service, Community Asset markers
var markerSC, sc;
for (sc = 0; sc < locationsSC.length; sc++) {
markerSC = new google.maps.Marker({
position: new google.maps.LatLng(locationsSC[sc][1], locationsSC[sc][2]),
map: map,
icon: {
url: 'https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png',
scaledSize: new google.maps.Size(25, 25)
}
});
google.maps.event.addListener(markerSC, 'click', (function(markerSC, sc) {
return function() {
infowindow.setContent(locationsSC[sc][0]);
infowindow.open(map, markerSC);
}
})(markerSC, sc));
}
</script>
</body>
</html>
問題在我的代碼中?還是Dropbox?
我剛剛開始學習JavaAcript;大部分代碼都是通過各種教程複製的(通過鍵入)代碼片段。
我沒有關於在代碼中粘貼實際文件路徑的疑慮。無論如何,該文件位置將被公開。如果任何人都能想到一個很好的理由,我不應該這樣做,隨時可以這麼說 - 爲什麼。
最重要的是,在此先感謝。
在記錄時間內的工作答案!非常感謝你。另外,今天我瞭解到,提問人員點擊「已回答」按鈕之前,必須發佈問題十分鐘。我會盡快做到這一點。 –