Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In form-display configuration for a content type, one can set the default zoom and styling of a Geolocation Google Geocoder, but I can't see a way to set the initial center of the map, which defaults at sea at 0,0.
It would be great to be able to set a center by lat/lng. This would not set the geolocation field value, but would just center the map so that users could avoid dragging the map a lot to figure out where they want to place a marker.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2804385-11-default-geocoding-widget-settings.patch | 17.34 KB | ChristianAdamski |
#4 | default-center-option-GeolocationGoogleGeocoder-2804385-4.patch | 2.82 KB | juliencarnot |
Comments
Comment #2
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedSounds good. Patch welcome :)
Comment #3
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedOh, actually, while you are at this: we might also add an option to trigger the client location automatically, if no value is set yet? Sounds useful to me, aye?
Comment #4
juliencarnot CreditAttribution: juliencarnot commentedOk, gave it a try, wasn't that complicated following your example! ;-)
I separated lat and lng in 2 fields to clarify syntax, and took the liberty to set default zoom at 5, so that the default map at 0,0 is easier to identify and pan...
Works for me, hope it will for you!
As for the automatic client location, wouldn't that overlap with https://www.drupal.org/node/2777753 ? I'll give it a try later but I'm really not sure I'll manage to tackle that one!
Comment #5
juliencarnot CreditAttribution: juliencarnot commentedComment #6
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedHey Julien,
thanks for the effort. This does not work though. The Google Settings stuff is used for all maps, including the common map stuff which has it's very own magic to determine the center.
The settings for lat/lng have to explicitly be tied to the google geocoder widget.
I think it's not hard. Just move the settings to the widget and alter the widget JS.
Comment #10
juliencarnot CreditAttribution: juliencarnot commentedWell, that was looking too good to be true! ;-) It didn't seem to affect my common map views but it is indeed in the views settings...
Thanks for taking time to review the patch, explain the problem and point to the solution. I've just had a look at GeolocationGooglegeocoderWidget.php and geolocation-widget-googlegeocoder.js but I don't really see where/how to move this and I don't have enough time right now to figure it out by trial and error.
If somebody with actual coding skills wants to give it a try, I'll be happy to learn how it should have been done and to test it!
Comment #11
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commented- shuffled some stuff around, minor typo fixes, separated coder a little more where due, added correct description
- added default Lat Lng to geocoding widget
- added option to trigger client location on load when value not yet set
- added option to set marker at said position, when former option is enabled
- fixed weired CSS for map controls location indicator
- added schema where due (hopefully)
Please test.
Comment #13
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedComitted. Let's see what breaks.