Search code examples
htmlgoogle-maps-markersdropboxmarkers

Google Map won't pull marker symbol from Dropbox


I'm doing a google map with custom symbols on locations provided by the client. Pasted below is a simplified version. When I set the path to the marker graphic .png in my own hard drive, and view the map in my own browser, everything works fine: The custom markers appear in the correct locations.

However, when I set the path to the marker .png in Dropbox, the marker does not appear on the map- neither with nor without the "?dl=0" suffix that Dropbox adds to the filename. I've also tried keeping the graphic on my Google Drive and pulling it from there; That didn't work either.

<!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>

Is the problem in my code? Or is it Dropbox?

I'm just beginning to learn JavaAcript; Most of the code is snippets copied (by typing) from various tutorials.

I have no qualms about pasting the actual file path in the code here. That file location is going to be public anyway. If anyone can think of a good reason I shouldn't do this, feel free to say so- and why.

Above all, thanks in advance.


Solution

  • https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png isn't a link to an image. It's a link to a web page that (among other things) shows you the image.

    To get a link to the image itself, try https://www.dropbox.com/s/set461kj7rt1zv5/ServiceBrownCog.png?raw=1. For more details, see https://www.dropbox.com/help/201.