Skip to content

Commit

Permalink
Merge pull request #130 from jyee/event_map
Browse files Browse the repository at this point in the history
Added event_map short code
  • Loading branch information
mattstratton committed Apr 14, 2016
2 parents 5db77f6 + eac1833 commit 36861c2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/events/sample-event/location.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type = "event"
draft = true

+++
<h4>

Information about the venue including address, map/direction, parking/transit, and any hotel group discount codes.
<p>

<!-- {{< event_map >}} -->
36 changes: 36 additions & 0 deletions layouts/shortcodes/event_map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ $path := split .Page.Source.File.Path "/" }}
{{ $event_slug := index $path 1 }}
{{ $e := (index .Page.Site.Data.events $event_slug) }}

{{ $coords := split $e.coordinates "," }}
{{ $lat := index $coords 0 }}
{{ $lng := index $coords 1 }}

<link href="/css/googlemaps.css" rel="stylesheet">

<div id="map_canvas" style="width: 550px; height: 265px"></div>

<script type="text/javascript" language="javascript">
function initMap() {
var mapDiv = document.getElementById("map_canvas");
var position = new google.maps.LatLng({{ $lat | safeJS }}, {{ $lng | safeJS }});

var map = new google.maps.Map(mapDiv, {
center: position,
zoom: 14,
mapTypeID: google.maps.MapTypeId.ROADMAP
});

var marker = new google.maps.Marker({
position: position,
map: map,
title: "{{ $e.location | safeJS }}",
});
}

window.onload = function() {
initMap();
};
</script>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyC1bvNK9qFJGEhoWNbQuojmJJ1Tg0DoOew"></script>

0 comments on commit 36861c2

Please sign in to comment.