In my google maps activity,the map is shown based on the current position.So i need to adjust the zoom controls of the map so that my current point and target point is always visible in the map.I think i need to be more specific.ie,I have a target address that is shown by an overlay image.My current position is focused on the map.So as I move away from the target,I need to adjust the zoom controls so that the target is still visible.Similarly,When I move close to target,I need to zoom in.
Check this answer here they have given code to zoom to the level to show each Overlay Marker drawn on the map so each of them are visible..may be this can solve your problem
LINK TO THE QUESTION
Use the following methods of MapView:
mapView.getController().setZoom(13); // set the zoom level here
mapView.getController().setCenter(point);
where mapview is the instance of MapView.
Hope this is what you want.
Related
I have multiple markers set around on the map. What I want to know is how can I show only a few markers depending on the zoom level. For example: I have a zoom on the map with radius: the length between the center of the map and the bounds of the screen (lets say this is like 2km in real life not sure if this is true) so I want to show only the markers that are inside the radius. And of course if the user zooms out the radius will be recalculated again from the center point of the map to the bound of the screen. And again include markers that are inside the new radius. How can I achieve this?
I have thought about this problem and here could be an approach.
you can loop through your available markers and find distance from the center of your given circle (since we're talking about a radius) to the marker; this can be done using computeDistanceBetween(); for more info see link
If the marker lies within your radius, show, otherwise, hide using the setVisible() method. For more information, see link
Hope this gives you some idea.
I want to get coordinates from set pixel from mapView.
In this code I get coordinates, but it's for the next region:
mapView.getProjection().fromScreenLocation(point);
You should consider use Google maps api v2 and use a fragment instead a simple mapview The info that you need is here
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/LocationSource
I hope that it can help you
I have a MapView with one overlay. Overlay renders tile based map over the MapView. I use MapView.getZoomLevel() to retrieve current zoom level for Google map and for my tiles. Everything works just perfect, but only if user don't zoom the map using multitouch gestures. As I understand, the MapView control don't render actual tiles during zooming process, but just show stretched screen content. So, the question is - How to get this scale ratio which I can use to render my tiles exactly in same way as Google do?
Thank You!
Although the method MapView.getZoomLevel() isn't aligned with zoom changes animation and multitouche, the methods MapView.getProjection().fromPixels() and MapView.getProjection().fromPixels() are.
So you have several option to adress the issue. From the methos above, you can find the direct (x,y) coordinates (and size) where to render the tiles or you can find the zoom ration using something like:
int lonSpan = projection.fromPixels(0,mapView.getHeight()/2).getLongitudeE6() -
projection.fromPixels(mapView.getWidth(),mapView.getHeight()/2).getLongitudeE6();
which gives you the longitude span at map vertical center. Then, you divide the value after zoom starts from the value before zoom starts.
Regards.
I have one marker displayed and centered in my ItemizedOverlay in maps, currently I call setZoom(19).
But how can I control the zoom level? i.e. I want to zoom in as detailed as possible, but still showing the map in satellite mode clear.
I have noticed that if you zoom in to far everything just goes black. How can I zoom into the most detailed level without going to far?
Any help most appreciated...
Just use
setZoom(mapview.getMaxZoomLevel());
https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapView
the solution is: look at the UiSettings in api v2 reference, there is the "setMaxZoomLevel" and "setMinZoomLevel".
Setup the max zoom level to the one that doesn't show a black screen (make some tests), then call the setZoom(mapview.getMaxZoomLevel());
Regards.
I'm trying to solve the following problem with MapView in an Android aplication:
I draw a static overlay over the map, it's position is relative to screen top and I use its (x,y) point to detect and reverse geocode a location underneath it.
When I zoom using built-in zoom controls, the map center position is not changed and consequently the address marker points to is also the same regardless of zoom level.
However, when I zoom via multitouch, the map center is moved aside and in result my marker points to a new address after the zoom is finished.
Can someone please suggest a solution on how to stick to the same address when zooming the map via multitouch?
Thanks