Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User geolocation in Google Maps #784

Merged
merged 22 commits into from
Nov 13, 2024

Conversation

stevygee
Copy link
Contributor

  • Adds parameter 'mylocation'
  • When enabled, geolocation toggle button is shown in map UI
  • Adds marker and accuracy circle to map
  • Watches user position, re-centers map
  • When dragged, position keeps updating, but map no longer follows
  • Geolocation can be turned off
  • Fixes AJAX markers not updating when changing center only

Fixes #98

@@ -273,7 +280,7 @@ public function newMapId(): string {
}

public function getResourceModules( array $params ): array {
return [ 'ext.maps.googlemaps3', 'ext.maps.googlemaps3ajax' ];
return [ 'ext.maps.googlemaps3', 'ext.maps.googlemaps3ajax', 'ext.maps.mylocation' ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you always load the new js file anyway, you could put it in one of the existing modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm not very familiar how script loading works in MediaWiki, but I've added it to the ext.maps.googlemaps3 module now.

@JeroenDeDauw
Copy link
Member

Do you have a demo of this somewhere? Or a short video?

@Flexmaen
Copy link

Do you have a demo of this somewhere? Or a short video?

Here: https://baugeschichte.at/Spezial:KU/ff9
Might mike more sense if you use it in your phone, and with a fake location set to some point that has entries around.

@stevygee
Copy link
Contributor Author

Added: The user location setting is now remembered (local storage), so it remains active for all maps on a site.

Added two new parameters:

  • mylocationfollow: When tracking user location, also follow user location by re-centering map on them (on/off).
  • mylocationzoom: Level to zoom to when activating user location. Set at -1 to disable (default).

(both of these are disabled in the demo)

@PeterTheOne
Copy link
Contributor

Looks good to me :)

@JeroenDeDauw JeroenDeDauw merged commit 543c5b2 into ProfessionalWiki:master Nov 13, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get user's current coordinates from browser
4 participants