Files
blog/_layouts/gallery-map.html

51 lines
2.1 KiB
HTML

---
layout: post
---
<section class="post-content">
<a href="/{{ site.baseurl }}/gallery/{{ page.gallery }}/">[ list ]</a>
</section>
<div id="googlemap" style="height:400px;margin-top:8px;"></div>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key={{ site.maps }}&amp;sensor=false"></script>
<script type="text/javascript">
google.maps.event.addDomListener(
window,
'load',
function () {
var map = new google.maps.Map(
document.getElementById("googlemap"),
{
center : new google.maps.LatLng({{ page.map.latitude }}, {{ page.map.longitude }}),
mapTypeId : google.maps.MapTypeId.TERRAIN,
zoom : {{ page.map.zoom }}
}
);
{% for photo in page.photos %}
{% if photo.location %}
(function () {
var wo = false;
var m = new google.maps.Marker({
position: new google.maps.LatLng({{ photo.location.latitude }}, {{ photo.location.longitude }}),
map : map,
title : "{{ photo.title }}"
});
var w = new google.maps.InfoWindow({
content: '<div style="margin-bottom:5px;">{{ photo.title | replace:"'","\\'" }}</div><a href="/{{ site.baseurl }}/{{ photo.url }}"><img alt="Photo: {{ photo.title | replace:"'","\\'" }}" height="200" src="{{ site.asset_prefix }}/gallery/{{ page.gallery }}/{{ photo.name | remove:'.md' }}~200x200.jpg" title="{{ photo.title|replace:"'","\\'" }}" width="200" /></a>'
});
google.maps.event.addListener(
m,
'click',
function() {
if (wo) {
w.close();
} else {
w.open(map, m);
}
wo = !wo;
}
);
})();
{% endif %}
{% endfor %}
}
);
</script>