Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To trigger the click event on one of the markers, you can simply do:</p> <pre><code>&lt;a href="javascript:google.maps.event.trigger(m1, 'click');"&gt;Trigger Click on m1&lt;/a&gt; </code></pre> <p>However, it looks like you have some further problems in your code, because you're mixing methods from the <a href="http://code.google.com/apis/maps/documentation/javascript/v2/" rel="nofollow noreferrer">v2 API</a> and the <a href="http://code.google.com/apis/maps/documentation/javascript/" rel="nofollow noreferrer">v3 API</a>. For example, both the <code>addOverlay()</code> and <code>openInfoWindowHtml()</code> methods do not exist in the v3 API.</p> <p>Therefore, your code should look something like this to work with the v3 API:</p> <pre><code>var map = new google.maps.Map(document.getElementById("map"), { zoom: 11, center: new google.maps.LatLng(35.26, -93.80), mapTypeId: google.maps.MapTypeId.ROADMAP }); // You only need one InfoWindow object var infowindow = new google.maps.InfoWindow(); // Create the markers, and keep a reference to them var m1 = new google.maps.Marker({ position: new google.maps.LatLng(35.2602340, -93.7939480), map: map }); var m2 = new google.maps.Marker({ position: new google.maps.LatLng(35.2810510, -93.8246510), map: map }); // Add the events listeners on the markers google.maps.event.addListener(m1, 'click', function() { infowindow.setContent('1&lt;br /&gt;test,TX'); infowindow.open(map, m1); }); google.maps.event.addListener(m2, 'click', function() { infowindow.setContent('test&lt;br /&gt;test,Texas'); infowindow.open(map, m2); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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