Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
diff --git a/templates/gmap3.html b/templates/gmap3.html
index 5481dc9..ffb5ec2 100644
--- a/templates/gmap3.html
+++ b/templates/gmap3.html
@@ -5,8 +5,9 @@
{% block head_override %}
<script type="text/javascript">
var bounds = new google.maps.LatLngBounds();
+ var infoWindow = new google.maps.InfoWindow();
- function buildMarker(map, latitude, longitude, name, color) {
+ function buildMarker(map, latitude, longitude, name, color, info_html) {
var latlng = new google.maps.LatLng(latitude, longitude);
var marker = new google.maps.Marker({
position: latlng,
@@ -15,6 +16,17 @@
});
marker.setIcon('http://maps.google.com/mapfiles/ms/icons/' + color + '-dot.png');
bounds.extend(latlng);
+
+ google.maps.event.addListener(marker, 'click', function() {
+ if(info_html == null) {
+ infoWindow.setContent(name);
+ }
+ else {
+ infoWindow.setContent(info_html);
+ }
+ infoWindow.setPosition(latlng);
+ infoWindow.open(map);
+ });
return marker
}
@@ -29,7 +41,7 @@
{% for object in object_list %}
- {% if object.point %}marker{{ object.pk }} = buildMarker(map, {{ object.point.y }}, {{ object.point.x }}, "{{ object }}", 'red');
+ {% if object.point %}marker{{ object.pk }} = buildMarker(map, {{ object.point.y }}, {{ object.point.x }}, "{{ object }}", 'red', "{{ object }}<br>{{ object.comments }}");
{% endif %}
{% if object.mpoly %}
var polygon{{ object.pk }}Coords = [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment