-
-
Save adamfast/a3e44d8e1c4de5a99d1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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