I've been unable to find an example how to limit scrolling of android Google maps to defined coordinates or preferably not outside a ground overlay.
There are some examples of extending MapView and overriding the onScroll method, but the MapViewActivity which MapView needs, seems to be deprecated.
I am currently using GoogleMap class with SupportMapFragment, which seems not to support such a thing.
there is this question with an answer which is a bad hack and I rather not use it.
So is it possible?
Not possible without bad hacks as of 3.1.36. You may want to post a feature request on gmaps-api-issues if nobody requested that already.
Related
Recently, Google Maps Android API v2 has been released, introducing MapFragment. It seems like a neat feature. However, I was wondering if it would be possible to use a MapView with the MapFragment to display a custom map instead of having a map loaded by the Google Play Services.
Looking at the documentation for MapFragment, I couldn't find any methods that would allow to attach a custom MapView. Moreover, it seems like you can never replace the GoogleMap that is used in the MapFragment.
For me this seems like, in order to be able to use custom maps, you cannot use the new maps API. I would appreciate the input of more knowledgeable people on this matter.
Edit: I would appreciate if someone could add the android-mapfragment tag, thereby creating it. Feel free to remove this edit once you have done so.
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
I am wondering about the correct approach or maybe the difference between the following if my intention is to put 2 markers on the map and maybe remove them after a while.
Should I use the overlays to put them, or should I use the canvas.draw (or just draw) to put them or simply add the two images as a view and using the layout param I can set the location. I found the last one being the easiest but I need your input
Thank you.
Don't be surprised, this is a terrible question. Other than your two tags, you don't explain anything about the platform you're building on.
If you're building an Android app, you'd probably want to use the maps Overlay.
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Overlay.html
If you're building a web app, I would use the Google Maps Javascript API Marker.
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Markers
If you're not using either, or are not using Google Maps, I have no clue how you expect people to read your mind over the internet.
Is there a way to make a marker on the MapView bounce? I mean already provided by the mapview (like the web google map).
Or I'll have to write my own code for animation for this?
Unless it's been added recently to the Maps API, I believe you'll need to do the animation yourself. There's a similar question here that may help you.
This may not be possible, but I would like to change how maps look in the Android app I'm working on. I've gotten the basic functionality working via the MapView class, but I can't find any information on how I might change how the maps are rendered. For instance, I might want the background to be black instead of the normal tan. Any ideas?! Hack answers are fine at this point if there aren't any standard ways to do this.
You could try putting a transparent overlay item with a tinge.
The MapView has a couple of modes like Satellite terrain
Try using OpenStreetMap for Android for a different look