I´m using the code provided by Stephen Potell for displaying WMS tiles in osmdroid. (https://groups.google.com/forum/?fromgroups=#!topic/osmdroid/WtRrQCIfYVk)
At first it seems like the tiles are displayed correct. After adding a my location overlay or an path overlay the tiles or the overlays are displayed incorrect. Assuming the overlays are correct it may seem like the tiles are either one zoom level wrong or the tiles are displayed "one tile off in y-direction".
When enabling multitouchControls in OSMDroid and barely zoom in (just one slight touch) and "hold the zoom" the tiles and overlays are in right location. If going one zoom level in or out the overlays are again positioned wrong.
I have tried playing around with values in WMSMapTileSource but with no luck.
Any help would be appreciated.
Ole T.
Related
maybe my question is so stupid, but... I would like to load image into map. I mean, I need to have all possibilities to draw markers on my map, but a background should be totally custom. Is it possible with osmdroid or something different?
You can use custom tilesource with youre image sliced into tiles (tiles are little square images containign little areas of map for particular zoom). So you'll have to slice your image and place slices in a proper directory structure according to their golocation. I guess you can find plenty of tools which can help you with slicing. If you don't have more "zooms" of the image you can lock mapview in one particluar zoom (so zooming will not work).
I have been searching in the documentation and throughout google. I would like to know if it is possible to place an image over the map the api comes from to use something else as a visual but with the maps gps functionality. Does anyone know if this is possible?
You can use two types of Overlays:
TileOverlays (reference)
A TileOverlay defines a set of images that are added on top of the base map tiles. You can also use tile overlays to add extra features to the map by providing transparent tile images. You need to provide the tiles for each zoom level that you want to support. If you have enough tiles at multiple zoom levels, you can supplement Google's map data for the entire map.
GroundOverlay (reference)
A ground overlay is an image that is fixed to a map. Unlike markers, ground overlays are oriented against the Earth's surface rather than the screen, so rotating, tilting or zooming the map will change the orientation of the image. Ground overlays are useful when you wish to fix a single image at one area on the map. If you want to add extensive imagery that covers a large portion of the map, you should consider a Tile overlay.
Background: I want to draw several Polygons on a map (few thousand coordinates in all). This worked pretty fast on Google Maps V1 by Overlays. But Google Maps V2 seems to be ineligible for that.
First of all I tried to add polygons directly to the map by
googleMap.addPolygon(myPolygonOptions);
but this is not just unusable slow, it seems to be buggy too, because it always forgets some polygons.
Then I tried to draw the polygon on an invisible view placed above the map, by drawing paths. But the method
projection.toScreenLocation(geoCoordinate);
is a joke to its "toPixels" Google Maps V1 counterpart. Where Google Maps V1 takes 1 second, Google Maps V2 takes 21(!) seconds, so this is unusable too.
Then I thought about giving Overlays a try. Ground overlays seems to be what I'm looking for:
A ground overlay is an image that is fixed to a map. Unlike markers,
ground overlays are oriented against the Earth's surface rather than
the screen, so rotating, tilting or zooming the map will change the
orientation of the image. Ground overlays are useful when you wish to
fix a single image at one area on the map.
But then I read a comment in this posting that it is not performant too and doesn't even work well.
So the last hope are Tile Overlays. The question is: What happens with tile overlays when I rotate the map. Do they change their orientation too or will they stay oriented as loaded?
[UPDATE]
I tried GroundOverlays and they are pretty fast, even on old Smartphones, so I will choose this approach.
The tile will be rotated together with the map. The TileProvider will not get aware of the rotation at all. While drawing the tile is always oriented north up. You may have a look at the answer to this SO question for a very handy tile provider: Google Maps API v2 draw part of circle on MapFragment
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 followed the tutorial for map overlays that Google offers (http://developer.android.com/resources/tutorials/views/hello-mapview.html) and it works fine, except the image for the overlay doesn't scale when you zoom in and out. I have Maps zoomed in on a city, and I want to put markets on several of the buildings, but the overlay image doesn't scale when it zooms in. Is there a way to have the overlay image scale up and down as users zoom in and out?
I have seen the answer where they used vector circles as the points on the map. That wont work for me, because I need to use custom images as the point on my map.
If you want to see my code, I can post it, but it is the exact the same as the example, except for some variable name changes.