Google地图不会从Dropbox

时间:2015-09-24 05:11:09

标签: html google-maps-markers dropbox markers

我正在使用客户端提供的位置上的自定义符号进行谷歌地图。下面粘贴的是简化版。当我在自己的硬盘中设置标记图形.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;大多数代码都是从各种教程中复制(通过输入)的片段。

我对在此处代码中粘贴实际文件路径没有任何疑虑。无论如何,该文件位置将是公开的。如果有人能想出一个我不应该这样做的好理由,请随时说出 - 以及为什么。

最重要的是,提前谢谢。

1 个答案:

答案 0 :(得分:0)

https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png不是指向图片的链接。它是指向(以及其他)向您显示图像的网页的链接。

要获取图片本身的链接,请尝试https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png?raw=1。有关详细信息,请参阅https://www.dropbox.com/help/201