Google 地图不会从 Dropbox 中提取标记符号
Google Map won't pull marker symbol from Dropbox
我正在制作 google 地图,在客户提供的位置上使用自定义符号。下面粘贴的是简化版本。当我在我自己的硬盘驱动器中设置标记图形 .png 的路径,并在我自己的浏览器中查看地图时,一切正常:自定义标记出现在正确的位置。
但是,当我在 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;大多数代码是从各种教程中复制(通过键入)的片段。
我毫不犹豫地将实际文件路径粘贴到此处的代码中。无论如何,该文件位置将是 public。如果有人能想到我不应该这样做的充分理由,请随意说出原因。
最重要的是,提前致谢。
https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png 不是图像的 link。它是 link 到一个网页,(除其他外)显示图像。
要获取图像本身的 link,请尝试 https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png?raw=1. For more details, see https://www.dropbox.com/help/201。
我正在制作 google 地图,在客户提供的位置上使用自定义符号。下面粘贴的是简化版本。当我在我自己的硬盘驱动器中设置标记图形 .png 的路径,并在我自己的浏览器中查看地图时,一切正常:自定义标记出现在正确的位置。
但是,当我在 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;大多数代码是从各种教程中复制(通过键入)的片段。
我毫不犹豫地将实际文件路径粘贴到此处的代码中。无论如何,该文件位置将是 public。如果有人能想到我不应该这样做的充分理由,请随意说出原因。
最重要的是,提前致谢。
https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png 不是图像的 link。它是 link 到一个网页,(除其他外)显示图像。
要获取图像本身的 link,请尝试 https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png?raw=1. For more details, see https://www.dropbox.com/help/201。