Is it possible to handle simultaneous zoom and pan events using a MapView?
The Google Maps app for Android allows the map to be panned while a pinch-to-zoom gesture is already underway. This is helpful for making fine adjustments while you zoom in on a region of the map. The default MapView does not seem to support this.
I am prepared to implement this functionality myself, but I would prefer to use the built-in mechanisms.
I solved this problem using an Overlay. By overriding the overlay's onTouchEvent() and detecting when zoom and pan events happen, those events can be handled in parallel.
For anyone facing this problem, I have posted a sample project based on my solution.
EDIT:
The new Google Maps v2 library supports simultaneous zoom and pan. Unless there is a need to customize the event handling algorithm, I strongly recommend upgrading to the new library.
Related
I am trying to make a Pokemon GO clone (educational work) and I know there are several possible ways to style the Google Maps using layout tricks or MapBox. My biggest challenge is to add a 3d object/model to the map and using gestures to zoom and pan around my character.
Somehow the camera should be fixed to the object (marker?) and panning/zooming should be disabled on the map but the gestures should rotate the camera around the character. I was wondering if someone can shoot me in the right direction on how to implement such feature using the native Android SDK and Google Maps/MapBox
Since Pokemon GO is not using Google Maps, I am wondering how they implemented their own map stuff, but this is outside the scope of this question.
(I am not looking for a paid solution such as here.com or nutiteq )
Mapbox Android SDK doesn't currently support 3D object, In this use case, i'd recommend using Mapbox alongside Unity instead which is made for these purposes. Here's a great blog post showing off how to do this.
I'm developing an app using osmdroid (3.0.8).
When I zoom using two fingers in and out, the zoom starts from the center of the map, not from the middle of the two fingers (using MapView.setMultiTouchControls(true);). I've tried to implement the pinch (pinch) but with bad results.
I've read other similar questions but without finding a good solution.
Note: I MUST use OSM, and not other solutions
Osmdroid 3.0.10 includes support for zooming at the location you pinched at.
The samples also include a two-finger rotation gesture overlay if that is something you are interested in trying.
I am looking for a way to receive events when a map finished panning or zooming or panning and zooming. Those events are not fired, afaik, from MapActivity in the SDK for Android 2.3.3 which I use. I tried the MapChange library, however, it forces you to use Handler in your MapActivity to ensure to that UI updates are processed on the UI thread; more information.
Question: Do you know of any support for such events by the Android Support Library e.g. by using FragmentActivity instead of MapActivity - I could not find an alternative solution by now.
Similar questions can be found here:
Android MapActivity on map movement
How to catch that map panning and zoom are really finished?
Edit:
The MapChange library was updated some hours ago. I will check out what has been improved.
Edit:
The MapChange library has been improved and works much more reliable now and is a good option! Please checkout the GitHub project for further information. However, I leave the question open since I am still interested whether one can do the same with existing components.
You can use the GoogleMap.OnCameraChangeListener to assign a listener to the changing camera event. Handling that and other events is discussed in the Google Maps Android API documentation.
Why is it a problem to use a Handler ? You can always post your UI changes to the main thread, why not do that ?
Someone on SO found a way to get a Fragment activity to contain a MapView by changing the support library code but it became too cumbersome for me to use and I reverted to a full-blown Map activity.
For anyone still looking for an answer to this
googleMap.setOnCameraIdleListener {
//Do your thing
}
called when camera movement has ended
Is pinch zoom functionality in Google map is possible, i have made several search but didn't get any solution, please give your view.
Or need to write the api for implementing these functionality.
Are you using ScaleGestureDetector to achieve Pinch and Zoom?
http://developer.android.com/reference/android/view/ScaleGestureDetector.html
Refer to this blog post on how to leverage multi touch in Android
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
I am developing an application in Android in which I'm using google map using the Javascript V3 library with Phonegap. It works fine for me until I noticed that map is zooming in on touch event but couldn't able to zoom out when I tried for number of times.
I'll appreciate if someone suggest me how I can get the pinch zoom in and out without using the default zoom controls of Google Maps?
Unfortunately there is no built-in function for this (not yet anyway), so in order to make it work you will have to create your own custom control for this action. This means capturing the touch event and zooming according to the gesture.
To go into a little more details on this, have a control over the map canvas, and in it capture the touch events.
Your second option since you are building for Android native is to use google maps from android (however this is java not javascript). You can find a basic tutorial on this here: http://mobiforge.com/developing/story/using-google-maps-android
Hope this helps,
Vlad