moagrius / MapView

(Deprecated, prefer https://github.com/moagrius/TileView) Android widget roughly described as a hybrid between com.google.android.maps.MapView and iOS's CATiledLayer
http://moagrius.github.com/MapView/documentation
69 stars 35 forks source link

Image moving between zoom levels #56

Closed phil-applegate closed 11 years ago

phil-applegate commented 11 years ago

Hi,

I believe this may be a bug in my implementation of the MapView rather than a bug with the controller itself but I thought I'd post to see if anyone else has had a similar issue.

I've created the tiled images for 4 different resolutions of an image these are loaded into the MapView controller and markers positioned over the top. The markers are positioned correctly for the highest zoom level but as you zoom out and change zoom levels (and therefore tileset) the image appears to jump/move so you will no longer be centered around the same point. Consequently the markers are not longer positioned in the corrected place in relation to the map. Just to clarify, when zooming across a zoom level the markers stay in the correct position in relation to the screen but the map appears to shift beneath them resulting in markers being incorrectly positioned.

Has anyone come across this before? Thanks in advance.

Phil

phil-applegate commented 11 years ago

The zoom levels I have added are as follows:

mapView.addZoomLevel(500,1500, filepath,downsample,500,500); mapView.addZoomLevel(1000,3000, filepath,downsample,500,500); mapView.addZoomLevel(2000,6000, filepath,downsample,500,500); mapView.addZoomLevel(3000,9000, filepath,downsample,500,500); mapView.addZoomLevel(4000,12000, filepath,downsample,500,500);

Does the fact the relationship between the zoom levels matter? I've noticed that if I remove the 3000,9000 level the problem no longer appears.

Cheers, Phil

moagrius commented 11 years ago

the widget expects each successive zoom level to be twice as large as the one preceding it. it shows the largest at 1.0 to 0.500001 scale, then the next largest at 0.5 to 0.250001, etc. That's why removing the 3000,9000 set "fixes" it - since that's the only one that's not twice as large as the previous. LMK if that doesn't make sense.

fcapano commented 11 years ago

I also faced this issue and couldn't understand the cause until I read this issue. In my opinion this behavior doesn't make much sense, as it leads developers to think that there is an issue with the tiled images. I would expect either that addZoomLever throws an exception if the zoomLevels are not "good", or that any zoom level can be added (which would be much better in my opinion). Either way, the error should probably not be treated "silently".

moagrius commented 11 years ago

there's no way to determine if a zoom level is "good" or not, and the dimensions don't have to be exactly half/double. On most of the apps I've produced with this widget, the zoom level dimensions vary somewhat, which generally ends up clipping or expanding the bottom and right borders, but you might have different aspect ratios on different zoom levels, for example, which is supported. There's also the ability to display marker sets for specific zoom levels.

In general, I don't consider this behavior to be an error, although the docs should probably be updated to state this clearly.

phil-applegate commented 11 years ago

Perfect - I've updated my implementation. I really appreciate you confirming this for me.

Thanks

moagrius commented 10 years ago

@phil-applegate TileView has been released and would support the levels as you have them listed in https://github.com/moagrius/MapView/issues/56#issuecomment-18901874 (although the signature is a little different now). TileView does not require "bit-shifted" levels, and detail levels can be added for any float value (e.g., 0.25, 0.5, 0.75, 1.0, 2.0).