Mikhail Korobov avatar Mikhail Korobov committed e586ce6

Default map template can now be used as a base template for custom map templates

Comments (0)

Files changed (1)

easy_maps/templates/easy_maps/map.html

-<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
-<div id="map-canvas-{{ map.pk }}" style="width: {{ width }}; height: {{ height }}}" class="easy-map-googlemap"></div>
+{% block api_js %}
+    <!-- Google Maps API javascript -->
+    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+{% endblock %}
 
-<script type="text/javascript">
-    function initialize() {
-        var latlng = new google.maps.LatLng({{ map.latitude }}, {{ map.longtitude }});
-        var myOptions = {
-            zoom: {{ zoom }},
-            center: latlng,
-            mapTypeId: google.maps.MapTypeId.ROADMAP
-        };
-        var mapElem = document.getElementById("map-canvas-{{ map.pk }}");
-        var map = new google.maps.Map(mapElem, myOptions);
+{% block html %}
+    <!-- HTML map container -->
+    <div id="map-canvas-{{ map.pk }}"
+         {% if width %}style="width: {{ width }}; height: {{ height }}}" {% endif %}
+         class="easy-map-googlemap">
+    </div>
+{% endblock %}
 
-        var marker = new google.maps.Marker({
-            position: latlng,
-            map: map,
-            title: "{{ map.address }}"
-        });
-    }
-    google.maps.event.addDomListener(window, 'load', initialize);
-</script>
+{% block map_js %}
+    <!-- Map creation script -->
+    <script type="text/javascript">
+        function initialize_map_{{ map.pk }}() {
+            var latlng = new google.maps.LatLng({{ map.latitude }}, {{ map.longtitude }});
+            var mapElem = document.getElementById("map-canvas-{{ map.pk }}");
+
+            {% block map_options_js %}
+            var mapOptions = {
+                zoom: {{ zoom }},
+                center: latlng,
+                mapTypeId: google.maps.MapTypeId.ROADMAP
+            };
+            {% endblock %}
+
+            var map = new google.maps.Map(mapElem, mapOptions);
+
+            {% block extra_js %}
+            var marker = new google.maps.Marker({
+                position: latlng,
+                map: map,
+                title: "{{ map.address }}"
+            });
+            {% endblock %}
+        }
+
+        {% block map_loading_js %}
+        // initialize the map after page loading
+        google.maps.event.addDomListener(window, 'load', initialize_map_{{ map.pk }});
+        {% endblock %}
+    </script>
+{% endblock %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.