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

Not all zoom levels available #27

Closed ghost closed 11 years ago

ghost commented 11 years ago

Hi,

I'm having an issue with zooming the map in portrait mode. My map has three zoom levels but I can only use two of the zoom levels in portrait mode, the lowest zoom level doesn't work. When I rotate the phone to landscape mode, all zoom levels are available. This problem occurred on an HTC One X and a Samsung Galaxy S3. On a HTC Sensation and a HTC Desire the zoom levels do work correctly in portrait mode. Any idea what might cause this?

frankowskid commented 11 years ago

I had similar problem. I think you should check two methods.

mapView.setScaleToFit(false); mapView.setScaleLimits(1 / Math.pow(2, lvl + 1), 1.0);

moagrius commented 11 years ago

@frankowskid is correct. By default the map view will never show "space", it'll always be as large as it needs to be to fill it's container along both axes. This will often mean on that very small tile sets won't be needed - I suggest keeping them in however for smaller or lower-density devices. In fact the best way to keep away from OOM errors is to supply even very small zoom levels (e.g., as large as the smallest display you expect to be on).

I couldn't think of any situation where this would not be appropriate, and had considered deprecating or removing the methods @frankowskid listed, but wasn't sure so just left them undocumented for now. I should mention that those methods haven't been thoroughly debugged, and I think I put in a hard cap of max scale 1 anyways.

ghost commented 11 years ago

@frankowskid thanks, that seems to have done the trick. My map does show some "space" now

@moagrius What would then be the behavior of the map when I have a non-square map? Then it should either show "space" or it would omit part of the map?

moagrius commented 11 years ago

@Joriz no, it "fits" the screen. So if you had a very wide, but short map (which I've had), it'd fit to the height of the container, and allow horizontal panning/scrolling.

ghost commented 11 years ago

OK, in that case something might be wrong with my tile set. In any case, @frankowskid solution solved the problem, even though it is with some "space" it will do for now.