-1

Can any suggest why this code doesn't provide 2 markers on my map?

http://pastebin.com/1uaNjeVy

I'm not sure whether it is a syntax error or a restriction by google?

Edit:

I got it working by doing the below anyway, apologies for not posting the code direct to here.

My new issue is that when I open the page sometimes it finds all of the addresses, other times it brings up the alert?

var geocoder = new google.maps.Geocoder();
        geocoder.geocode( {'address': "Eldon Square 24-26 Sidgate, Newcastle upon Tyne"}, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                        var img = "https://dl.dropboxusercontent.com/u/55888592/marker26.png";
                        var info = "<div><p>Sometext</p></div>";
                        var infowindow = new google.maps.InfoWindow({
                        });
                        var latlng = results[0].geometry.location;
                        var marker = new google.maps.Marker({
                                icon: img,
                                position: latlng,
                                map: map,
                                content: info
                                });
                        google.maps.event.addListener(marker, "click", function(content) {
                                infowindow.setContent(this.content);
                                infowindow.open(map,this);
                        });
                        } else {alert("alert");
                        }
                marker.setMap(map);
                });   
Kara
  • 6,115
  • 16
  • 50
  • 57
Paul Bentham
  • 356
  • 1
  • 6
  • 18
  • Please include the relevant code in your question, not just a link to pastbin. – geocodezip Dec 13 '13 at 18:27
  • How many markers? If it is more that ~11 you will get a status response of OVER_QUERY_LIMIT. The geocoder is subject to a quota and a rate limit, there are answers here on how to address that. The best approach is to use coordinates for markers and not use the geocoder for known addresses/places. – geocodezip Dec 13 '13 at 18:39
  • use a single geocoder-instance, the first one will be overwritten by the second – Dr.Molle Dec 13 '13 at 18:41
  • Possible duplicate of [OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?](http://stackoverflow.com/questions/11792916/over-query-limit-in-google-maps-api-v3-how-do-i-pause-delay-in-javascript-to-sl/11793406#11793406) – geocodezip Dec 13 '13 at 18:42

1 Answers1

0

The geocoder is asynchronous. Your are setting the marker map variable before the marker is created. You should do that in the callback function of the geocoder. (The javascript console is your friend)

And your marker images fail to load from the URL provided (probably because it is https)

working example

geocodezip
  • 158,664
  • 13
  • 220
  • 245