Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>gmarkers</code> variable is undefined. It simply does not reach part of appending it to the 'side_bar'. </p> <p>Also, why not to do this such way?</p> <pre><code> var sideClick = jQuery("&lt;a class=side_click href='#'&gt;&lt;/a&gt;"); $(sideClick).html(place.name); $("#side_bar").append(sideClick); $(sideClick).on("click", function() { google.maps.event.trigger(gmarkers[parseInt(gmarkers.length-1)], "click"); }); </code></pre> <p>The problem with your initial code - it can not access the <code>place</code> variable (besides the fact that <code>javascript:</code> is kind of bad practice). So, by putting it all into callback for <code>google.maps.event.addListener(searchBox, 'places_changed', function() {..}</code> it now can access <code>place</code> variable and get <code>name</code> value of current looping <code>place</code>.</p> <p>I am still not sure what is with <code>gmarkers</code> (maybe, it should be <code>markers</code> (misspeling)?). It did not declared anywhere.</p> <p>Here is working version (without <code>gmarkers</code> part, it is still broken): <a href="http://jsbin.com/ayugun/54/" rel="nofollow noreferrer">http://jsbin.com/ayugun/54/</a></p> <p>You may like to discover more about closures in JavaScript:<br> <a href="https://stackoverflow.com/questions/111102/how-do-javascript-closures-work">Good answers about it on StackOverflow</a>.<br> <a href="https://developers.google.com/maps/documentation/javascript/events" rel="nofollow noreferrer">Material from Google docs for the Maps.</a> (the part under <strong>Using Closures in Event Listeners</strong> header). This example is related to the Google Maps and great for showing what is closure in real life.</p>
    singulars
    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.
 

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