Prevent map from changing center location on zoom.
See original GitHub issueI’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.
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:
- Created 8 years ago
- Comments:26 (7 by maintainers)
Top GitHub Comments
@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.
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 });