Skip to content

Commit c73b5f1

Browse files
Pass and use the Default Centre setting as documented
1 parent 20f3968 commit c73b5f1

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

wagtailgmaps/static/wagtailgmaps/js/map-field-panel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class MapInputController extends window.StimulusModule.Controller {
55
this.geocoder = new google.maps.Geocoder();
66
this.latlngMode = Boolean(this.element.dataset.latlngmode);
77
this.zoom = Number(this.element.dataset.zoom);
8+
this.defaultCentre = this.element.dataset.defaultcentre;
89

910
// Trigger the event so the maps can start doing their things
1011
var event; // The custom event that will be created
@@ -129,7 +130,7 @@ class MapInputController extends window.StimulusModule.Controller {
129130

130131
// Set the map to the initial location
131132
controller.geocodeAddress(
132-
initValue,
133+
initValue || controller.defaultCentre,
133134
controller.textboxTarget,
134135
controller.marker,
135136
controller.map

wagtailgmaps/templates/wagtailgmaps/forms/widgets/map_input.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
data-lat="{{ lat }}"
66
data-lng="{{ lng }}"
77
data-latlngMode="{{ latlngMode }}"
8+
data-defaultCentre="{{ default_centre }}"
89
>
910
{% include "django/forms/widgets/text.html" %}
1011
<br/>

wagtailgmaps/widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def get_context(self, name, value, attrs):
3535
"latlngMode": self.latlngMode,
3636
"map_id": self.get_map_id(attrs["id"]),
3737
"zoom": self.zoom,
38+
"default_centre": self.default_centre,
3839
}
3940
)
4041

0 commit comments

Comments
 (0)