question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prevent map from changing center location on zoom.

See original GitHub issue

I’m attempting to recreate a “drag the map to set your location” feature in my app. This feature is very common on apps like Uber and Lyft, where you set the location of where you want to be picked up.

This is easily accomplished by adding a marker/pin icon on top of the map interface, setting that pin to the center, and finally you can use map.getCameraPosition(); to find the lat long of your set pin.

One major UX issue with this idea is when you pinch to zoom on the map. By default it will zoom and drag the map to the location of your fingers.

Here is an example of pre-zoom (notice the pin at the cross roads) and then after I zoom in using pinch.

img_0803

To solve this you must lock the map’s center position (ie. prevent dragging) when zooming.

Here is a post resolving this issues using the iOS SDK: http://stackoverflow.com/a/28158654/293585 I have yet to find any documentation on how to accomplish this via the Android SDK, but I will gladly put in the effort to find it.

Could this be implemented easily into this plugin and then set as an option via javascript?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
chadwhitakercommented, Jul 11, 2016

@vipinnegi90 Here is my forked version that contains the java solution. https://github.com/chadwhitaker/cordova-plugin-googlemaps

It still needs a little work and I’m open to pull requests.

0reactions
QVMastercommented, Jul 25, 2018

I used to reset map center to current location when map zoom changed.

google.maps.event.addListener(map, ‘zoom_changed’, function() { //here you can set map center to current location you hold before });

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Maps SDK iOS - prevent map from changing location ...
I have a GMSMapView with imageView in front of it in the center. In result - I can drag map and always have...
Read more >
Controlling Zoom and Pan | Maps JavaScript API
The following map demonstrates the default behavior for map interactions with a map instantiated with only the zoom and center options defined.
Read more >
Stop auto-zoom on "position centred" - Google Groups
How do I prevent the app from changing the zoom? I would like to keep my position always centred, and choose the zoom...
Read more >
Changing map properties programmatically - Packt Subscription
Users can zoom in/out, drag the map, change the user interface, or enable/disable ... The ones most used are to change the center...
Read more >
Selecting data center regions for meetings/webinars
Account · Sign in to the Zoom web portal as an admin with the privilege to edit account settings. · In the navigation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found