Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have never worked with infoBox, but I assume it is very similar to the standard info window. You need to use <a href="http://code.google.com/apis/maps/documentation/javascript/events.html" rel="nofollow">Events</a> to add the click action to the marker that will open the info box and center the map.</p> <p>Something similar to this:</p> <pre><code>//register the single left click event. google.maps.event.addListener(marker, "click", function (event) { //you may have to create a another box here or just change the content //Google's standard info window only creates one instance and then you change //the content during this event i.e. infoWindow.setContent("some html"); infoBox.open(map, this); map.setCenter(this.position); }); </code></pre> <p>Updated answer:</p> <p>Ok, it looks like you are overwriting the infoBox on every iteration through the loop so the only one left to show will be the last on created. You can build one infoBox outside of the loop but dont set the content attribute, then inside of the listener set the content.</p> <p>You need to store the content somewhere else to prevent it from being overridden as well. Try setting the content in the marker and refer to it like this </p> <pre><code>var boxText = document.createElement("div"); boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;"; boxText.innerHTML = locationname + "&lt;p&gt;" + 'No. of finds: ' + "&lt;b&gt;" + totalfinds + "&lt;/b&gt;" + "&lt;/p&gt;"; var marker = new google.maps.Marker({ map: map, position: point, title: address, icon: icon.icon, shadow: icon.shadow, html: boxText }); google.maps.event.addListener(marker, "click", function (event) { infoBox.setContent(this.html); infoBox.open(map, this); map.setCenter(this.position); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload