0

I'm playing with the Firefox addon Ubiquity. I'm trying to put a custom google map on the preview page. The page should contain the following:

<html>
<head>
  <title>Google Maps Multiple Markers</title>
  <script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;"></div>
<script type="text/javascript">
    var locations = ['Bondi Beach', 'Coogee Beach', 'Cronulla Beach', 'Manly Beach', 'Maroubra Beach'];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var marker, i;
    var geocoder = new google.maps.Geocoder();

    for (i = 0; i < locations.length; i++) {
        console.log("coding " + locations[i]);
        geocoder.geocode({'address': locations[i].toLowerCase()}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    }
  </script>
</body>
</html>

But the locations variable should be set by the input. The idea is to let the user map multiple locations (this functionality was once there, I'm trying to remake it). I've tried simply settings the pblock.innerHTML with that, but while it seems that it gets the input, nothing appears. I've tried reverse engineering the functionality of the default map command but I don't understand how it works.

Svalorzen
  • 5,353
  • 3
  • 30
  • 54

1 Answers1

0

I solved this by copying the whole file containing the map command and cutting all parts until I was left with only the parts that I needed. I'm still not sure why my old solution was not working though..

Svalorzen
  • 5,353
  • 3
  • 30
  • 54