Skip to content

Instantly share code, notes, and snippets.

@objectivehtml
Last active December 18, 2015 16:49
Show Gist options
  • Select an option

  • Save objectivehtml/5813663 to your computer and use it in GitHub Desktop.

Select an option

Save objectivehtml/5813663 to your computer and use it in GitHub Desktop.
<a href="#" class="reveal" data-reveal-id="map-modal" id="reveal-trigger" style="display:none">Reveal</a>
<div id="map-modal" class="reveal-modal"></div>
{exp:gmap:init id="map" style="width:400px;height:300px"}
{exp:channel:entries [YOUR PARAMS HERE]}
{your_map_field id="map" data:url="/your/ajax/template/URL_TITLE" [YOUR RETINA ICON PARAMS HERE]}
{/exp:channel:entries}
<script type="text/javascript">
// This example assumes your map id is "map".
// Loop through the global marker array
$.each(map_markers, function(i, marker) {
google.maps.event.addListener(marker, 'click', function() {
var url = this.data.url;
$.get(url, function(html) {
$('#map-modal').html(html);
$('#reveal-trigger').click();
});
});
});
</script>
@objectivehtml

Copy link
Copy Markdown
Author

Two things to note on this examples. 1) the .reveal-modal div is empty. AJAX populates the content (obviously). 2) The easiest way to trigger a reveal is to use a click(), but since you don't need a button, it is set to hidden. This is an important thing to note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment