-
Notifications
You must be signed in to change notification settings - Fork 91
Fix: preserve geopicker zoom, center map on user location on load, no error clicking pin #905
Conversation
This was a regression in the original `setgeopoint` work, when abstracting the geolocation code into `getCurrentPosition`
Also fixes the pin's width so it's no longer distorted
@@ -40,15 +40,15 @@ let searchSource = | |||
'https://maps.googleapis.com/maps/api/geocode/json?address={address}&sensor=true&key={api_key}'; | |||
const googleApiKey = config.googleApiKey || config.google_api_key; | |||
const iconSingle = L.divIcon({ | |||
iconSize: 24, | |||
iconSize: [16, 24], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does two things:
- Correct the width of map pins
- Prevent an error when clicking on the pin, where Leaflet's internal state calculating the pin's offset has
NaN
for the left side.
@@ -773,7 +773,6 @@ class Geopicker extends Widget { | |||
// update last requested map coordinates to be used to initialize map in mobile fullscreen view | |||
if (latLng) { | |||
this.lastLatLng = latLng; | |||
this.lastZoom = zoom; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain this isn't guarded here for a reason, but it seems like the event handler more likely is the expected behavior.
@@ -841,6 +840,16 @@ class Geopicker extends Widget { | |||
} | |||
}); | |||
|
|||
this.map.on('load', () => { | |||
this.map.on('zoomend', (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is wrapped in the load
event to ensure the initial zoom isn't treated as a user-initiated state change.
Seems ok to continue with this being untested for now. |
Closes #902. Grouping these together, initially for visibility/feedback because they all affect the Leaflet UI and would be challenging to test and I want to get a sense of how much interest there is in adding those tests anyway.