My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 4663: Add minZoom and maxZoom to GoogleMapOptions
76 people starred this issue and may be notified of changes. Back to list
Status:  Acknowledged
Owner:  ----


Sign in to add a comment
 
Reported by [email protected], Dec 6, 2012
When using a custom TileProvider / TileOverlay, it should be possible to constrain what zoom levels are available. For example, if an offline tile source is used (MBTiles or similar), the zoom levels available may only be 12-18. Allowing the user to zoom past these limits may be an undesired or poor experience.

Ideally, this could be accomplished by adding two new methods to the TileProvider interface.

public interface TileProvider {
    public Tile getTile(int x, int y, int zoom);

    public int getMinZoomLevel();

    public int getMaxZoomLevel();
}

These callbacks would be called by the TileOverlay or GoogleMap instance to determine when to disable the zoom gesture and UI controls.
Mar 24, 2013
#1 [email protected]
You can simply do:

if (zoom < 12 || zoom > 18) {
  return null;
}

in getTile.
Mar 25, 2013
#2 [email protected]
@#1: Sorry, but you are missing the point completely.

The point of these additions are not for the sake of the TileProvider, but for the GoogleMap instance. Right now, the zoom extents are set to internal constants relative to what Google can provide for its basemaps. The problem comes when the only TileProvider is a custom one (with MAP_TYPE_NONE) and it can only provide a limited set of zoom levels.

Returning null or Tile.NO_TILE from the TileProvider instance does NOT prevent the map from zooming in or out. Instead, the user is presented a black screen or gray grid, which is poor UX. The user is now confused and looses all sense of map location.

The ideal implementation in my honest opinion would be that the GoogleMap instance would ask all of its TileProviders for their min and maximum zoom levels, take the overall min and max, and then limit the map to only these zoom levels. In other words, the pinch gesture and onscreen +/- controls should respect these limited min/max values.
Mar 25, 2013
#3 [email protected]
I didn't read your original description carefully. "constrain what zoom levels are available" says it all.

Thinking of it, I would prefer GoogleMap.setMinZoomLevel and GoogleMap.setMaxZoomLevel (also in GoogleMapOptions and in xml). I could imagine an app that doesn't want user to zoom out too much even without custom tiles, e.g. when all markers and other visible objects are in one city.
Apr 2, 2013
#4 [email protected]
Yes, agree with #3. Changing description to match.
Summary: Add minZoom and maxZoom to GoogleMapOptions (was: Allow TileProvider to Specify Min / Max Zoom Levels)
Apr 20, 2013
#5 [email protected]
 Issue 5269  has been merged into this issue.
Nov 10, 2013
#6 [email protected]
I've run into this as well, using the Google Maps API but wanting to provide a custom tile set (i.e. it's not a map on Earth).  Is this in the plan?  Is there any kind of work-around until it is?
Nov 11, 2013
#8 [email protected]
(No comment was entered for this change.)
Status: Acknowledged
Labels: Internal-8549475
Nov 11, 2013
#9 [email protected]
Just FYI...  I dealt with this by creating a TileProvider that calls UrlTileProvider and, if it fails then zooming out until it works at which point I extract the proper internal rectangle, scale it up, re-encode it as a PNG from which I create a new Tile (because there doesn't seem to be a way to create a Tile from a Bitmap), and return 
that generated tile.  Works quite well, actually.

Some problems...

The Tile documentation at http://developer.android.com/reference/com/google/android/gms/maps/model/Tile.html is missing what formats are understood in the "byte[] data" and the link to TileCreator returns 404.

Other Tile documentation at https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Tile also has empty data for "CREATOR", no href to TileCreator, and the link at the bottom to "decodeByteArray(...)" is also 404.

The documentation for BitmapFactory is similarly missing what formats can be decoded.  I'd prefer not to re-encode my scaled image as PNG but rather create a new Tile directly from my scaled bitmap.

Dec 15, 2013
#10 [email protected]
I've hit this the opposite way.  My TileOverlay has details well beyond what Google Maps has but I can't continue to zoom in past zoom=19.  It  would be great to be able to set it as deep as I want.  If I want to show the notes in the margin of the calendar on a desk in the cabin of a ship in the middle of the Pacific Ocean, then I should be able to zoom in far enough to do so (as long as I'm providing the imagery myself, of course).

Granted, I expect a zoom limit of 31 is probably the largest practical amount.
Mar 20, 2015
#11 [email protected]
in general, camera limiting would be very useful on Gmaps. Both in zoom and in bounds/center of the camera. you can use a camerachangedlistener to achieve this, but it's still a weird experience
Oct 27, 2015
#12 [email protected]
The iOS Google Maps API has this exact functionality---odd that it's not present in Android.

https://developers.google.com/maps/documentation/ios-sdk/views#zoom
Sign in to add a comment

Powered by Google Project Hosting