Does anyone know the scale ratio for android mapview zoom values?
For example if I wanted to overlay an image that was say 1 degree GPS map space square.. what size in pixels should that be when the zoom is at maximimum? Then what would I need to scale the image by per zoom level?
Is this published or known anywhere?
To do this you need to use the getProjection method in the MapView clas
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html#getProjection()
but I don't believe you can scale overlays using the default methods, you may need to override or expand the drawAt method for the Overlay class.
Related
I'm trying to achieve that camera update would center between two positions
BUT if resulting zoom level is bigger than 12 it should be set to 12.
So i need some:
CameraUpdateFactory.newLatLngBounds(bounds,padding);
But instead of padding there should be max zoom level.
My solution requires that i calculate exact screen bounds that will be after camera update and here i got stuck.
If you need to calculate map screen bounds, you should use VisibleRegion
VisibleRegion visibleRegion = googleMap.getProjection().getVisibleRegion();
read also this question, may be similar to what you need.
I have tiles downloaded from Mobac tool, with the source being Openstreet mapQuest.
Given that we may not have tiles for all positions at a higher zoom level, when we scroll, areas that are missing tiles result in a null grid or stretched images of lower zoom-level tiles.
How can I restrict scrolling to only a given bounding box and zoom level?
Implementing MapListener interface, I overrode the OnZoom function. Depending upon current zoomlevel and the points visible on screen, the scrollable boundingbox can be set by calling mapView.setScrollableAreaLimit.
I have been playing around with the TileOverlay in Android Maps v2 and I have built a custom TileProvider very very similar to this one
But there is something that strikes me as odd. No matter which number I pass on to the Tile constructor, the image on the screen is always the same - 4 to 9 Tiles sharing the screen space evenly, like this:
Of course this is something you would expect from reading the documentation:
The coordinates of the tiles are measured from the top left (northwest) corner of the map. At zoom level N, the x values of the tile coordinates range from 0 to 2N - 1 and increase from west to east and the y values range from 0 to 2N - 1 and increase from north to south.
But you might guess that there is in fact such a functionality from looking at the Constructors documentation
Constructs a Tile. Parameters
width the width of the image in pixels
height the height of the image in pixels
data A byte array containing the image data. The image will be created from this data by calling decodeByteArray(byte[], int, int).
So obviously I misunderstood something here. My personal guess is that the tiles have to cover an entire "Map Tile" and can therefore not be shrunken
My goal would be to make my tiles about 10dp of the screen. Therefore again my question to you:
Can I realize this with TileOverlay or will I end up using custom Markers?
The size of the tile specified in the constructor is the size of (every) bitmap tile you are supplying to the map. This allows you to provide tiles at different densities for different screens if you have such resources.
It will not change the size of the image that is drawn on the map. The physical size of a map tile is defined by the zoom level, where a zoom level of 0 is a single tile covering the entire world, 1 is 2x2 tiles, etc. This is part of an open web map standard for map tiles, not defined by Google.
API docs:
https://developers.google.com/maps/documentation/android/tileoverlay
Ref:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
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 am developing an android map application. I need to overlay a route image which displays the route on the map. But, when we zoom in or zoom out the image will not scale with it because it is only anchored to a fixed center point. I want to anchor it with four boundary points such that it will scale with the map.
Can someone please suggest a good way of doing this?
You can scale a bitmap using the createScaledBitmap() method.