diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py index de8f75c5a0..cca5dc941f 100644 --- a/django/contrib/gis/maps/google/gmap.py +++ b/django/contrib/gis/maps/google/gmap.py @@ -21,7 +21,7 @@ class GoogleMap(object): def __init__(self, key=None, api_url=None, version=None, center=None, zoom=None, dom_id='map', kml_urls=[], polylines=None, polygons=None, markers=None, - template='gis/google/google-single.js', + template='gis/google/google-map.js', js_module='geodjango', extra_context={}): @@ -162,7 +162,7 @@ class GoogleMapSet(GoogleMap): # This is the template used to generate the GMap load JavaScript for # each map in the set. - self.map_template = kwargs.pop('map_template', 'gis/google/google-map.js') + self.map_template = kwargs.pop('map_template', 'gis/google/google-single.js') # Running GoogleMap.__init__(), and resetting the template # value with default obtained above. diff --git a/django/contrib/gis/templates/gis/google/google-base.js b/django/contrib/gis/templates/gis/google/google-base.js deleted file mode 100644 index f3a91edbc4..0000000000 --- a/django/contrib/gis/templates/gis/google/google-base.js +++ /dev/null @@ -1,7 +0,0 @@ -{% block vars %}var geodjango = {};{% for icon in icons %} -var {{ icon.varname }} = new GIcon(G_DEFAULT_ICON); -{% if icon.image %}{{ icon.varname }}.image = "{{ icon.image }}";{% endif %} -{% if icon.shadow %}{{ icon.varname }}.shadow = "{{ icon.shadow }}";{% endif %} {% if icon.shadowsize %}{{ icon.varname }}.shadowSize = new GSize({{ icon.shadowsize.0 }}, {{ icon.shadowsize.1 }});{% endif %} -{% if icon.iconanchor %}{{ icon.varname }}.iconAnchor = new GPoint({{ icon.iconanchor.0 }}, {{ icon.iconanchor.1 }});{% endif %} {% if icon.iconsize %}{{ icon.varname }}.iconSize = new GSize({{ icon.iconsize.0 }}, {{ icon.iconsize.1 }});{% endif %} -{% if icon.infowindowanchor %}{{ icon.varname }}.infoWindowAnchor = new GPoint({{ icon.infowindowanchor.0 }}, {{ icon.infowindowanchor.1 }});{% endif %}{% endfor %}{% endblock %} -{% block functions %}{% endblock %} \ No newline at end of file diff --git a/django/contrib/gis/templates/gis/google/google-map.js b/django/contrib/gis/templates/gis/google/google-map.js index e5f3a0e0e3..06f11e35f3 100644 --- a/django/contrib/gis/templates/gis/google/google-map.js +++ b/django/contrib/gis/templates/gis/google/google-map.js @@ -1,10 +1,16 @@ {% autoescape off %} +{% block vars %}var geodjango = {};{% for icon in icons %} +var {{ icon.varname }} = new GIcon(G_DEFAULT_ICON); +{% if icon.image %}{{ icon.varname }}.image = "{{ icon.image }}";{% endif %} +{% if icon.shadow %}{{ icon.varname }}.shadow = "{{ icon.shadow }}";{% endif %} {% if icon.shadowsize %}{{ icon.varname }}.shadowSize = new GSize({{ icon.shadowsize.0 }}, {{ icon.shadowsize.1 }});{% endif %} +{% if icon.iconanchor %}{{ icon.varname }}.iconAnchor = new GPoint({{ icon.iconanchor.0 }}, {{ icon.iconanchor.1 }});{% endif %} {% if icon.iconsize %}{{ icon.varname }}.iconSize = new GSize({{ icon.iconsize.0 }}, {{ icon.iconsize.1 }});{% endif %} +{% if icon.infowindowanchor %}{{ icon.varname }}.infoWindowAnchor = new GPoint({{ icon.infowindowanchor.0 }}, {{ icon.infowindowanchor.1 }});{% endif %}{% endfor %} +{% endblock vars %}{% block functions %} {% block load %}{{ js_module }}.{{ dom_id }}_load = function(){ if (GBrowserIsCompatible()) { {{ js_module }}.{{ dom_id }} = new GMap2(document.getElementById("{{ dom_id }}")); {{ js_module }}.{{ dom_id }}.setCenter(new GLatLng({{ center.1 }}, {{ center.0 }}), {{ zoom }}); - {% block controls %}{{ js_module }}.{{ dom_id }}.addControl(new GSmallMapControl()); - {{ js_module }}.{{ dom_id }}.addControl(new GMapTypeControl());{% endblock %} + {% block controls %}{{ js_module }}.{{ dom_id }}.setUIToDefault();{% endblock %} {% if calc_zoom %}var bounds = new GLatLngBounds(); var tmp_bounds = new GLatLngBounds();{% endif %} {% for kml_url in kml_urls %}{{ js_module }}.{{ dom_id }}_kml{{ forloop.counter }} = new GGeoXml("{{ kml_url }}"); {{ js_module }}.{{ dom_id }}.addOverlay({{ js_module }}.{{ dom_id }}_kml{{ forloop.counter }});{% endfor %} @@ -26,4 +32,4 @@ alert("Sorry, the Google Maps API is not compatible with this browser."); } } -{% endblock %}{% endautoescape %} +{% endblock load %}{% endblock functions %}{% endautoescape %} diff --git a/django/contrib/gis/templates/gis/google/google-multi.js b/django/contrib/gis/templates/gis/google/google-multi.js index 49ce584e36..e3c7e8f02b 100644 --- a/django/contrib/gis/templates/gis/google/google-multi.js +++ b/django/contrib/gis/templates/gis/google/google-multi.js @@ -1,4 +1,4 @@ -{% extends "gis/google/google-base.js" %} +{% extends "gis/google/google-map.js" %} {% block functions %} {{ load_map_js }} {{ js_module }}.load = function(){ diff --git a/django/contrib/gis/templates/gis/google/google-single.js b/django/contrib/gis/templates/gis/google/google-single.js index ab7901e42e..b930e4594f 100644 --- a/django/contrib/gis/templates/gis/google/google-single.js +++ b/django/contrib/gis/templates/gis/google/google-single.js @@ -1,2 +1,2 @@ -{% extends "gis/google/google-base.js" %} -{% block functions %}{% include "gis/google/google-map.js" %}{% endblock %} \ No newline at end of file +{% extends "gis/google/google-map.js" %} +{% block vars %}{# No vars here because used within GoogleMapSet #}{% endblock %} \ No newline at end of file