Skip to content

Instantly share code, notes, and snippets.

@objectivehtml
Created October 16, 2011 17:50
Show Gist options
  • Save objectivehtml/1291187 to your computer and use it in GitHub Desktop.
Save objectivehtml/1291187 to your computer and use it in GitHub Desktop.
<!--
Note, the id parameter will become a prefix to the javascript variables. In this example, the map's id is "map", thus all javascript variables have a prefix of "map_".
-->
{exp:gmap:init id="map" style="width:400px;height:300px"}
{exp:channel:entries channel="map"}
{exp:gmap:marker id="map" latitude="{map_latitude}" longitude="{map_longitude}"}
{title}
{/exp:gmap:marker}
<img src="{map_photo}" alt="Picture of {title}" data-index="{count}" class="map-photo" />
{/exp:channel:entries}
<script type="text/javascript">
$(document).ready(function() {
$('.map-photo').click(function() {
var $t = $(this);
var index = parseInt($t.data('index'));
//Closes any open markers
$.each(map_windows, function(i, infoWindow) {
infoWindow.close();
});
//centers map on marker
map_canvas.setCenter(map_markers[index].getPosition());
//opens window
map_windows[index].open();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment