8

I have some very high resolution aerial imagery that I would like to display over a satellite view base map. My imagery is good enough to generate images up to zoom level 23. However, Google's satellite view only allows zooming in to level 20. I know that I can manually switch the map type to my custom overlay once the user zooms in to level 20 (so only my map type is shown), but then I lose the Google imagery for a full zoom level.

My question is, is there some way to register for an event once the zoom reaches level 20, where the client is attempting to zoom in further but can't? If not, are there other ideas on how I can enable further zooming without losing the Google imagery at level 20?

The only other solution that I can come up with is to create a second custom tile server that simply forwards requests on to the standard Google tile url, but that offers a different min/max zoom. If this idea is the way to go, I would like to get confirmation on that as well. Thanks.

4
  • You can restrict zoom by defining maxZoom and minZoom properties within mapOptions.
    – Kay_N
    May 13, 2015 at 0:21
  • Yes, if I am only showing my map type. However, I have an overlay map type, so the min and max zoom level are specified on the built-in Satellite or Terrain map types. Do you know how to increase (not decrease) the max zoom level for those map types?
    – Jeff G
    May 17, 2015 at 0:20
  • Something like this? stackoverflow.com/questions/10517848/….
    – Kay_N
    May 19, 2015 at 0:47
  • That was a promising idea, but it doesn't work to expand the max zoom in Google Maps v3.19 when displaying the SATELLITE or HYBRID map types. I think it is because the max zoom is already set to 22 on both of those map types, yet the max zoom is set dynamically as if a call to MaxZoomService.getMaxZoomAtLatLng() was made.
    – Jeff G
    May 19, 2015 at 1:24

1 Answer 1

12

I determined that the simplest solution is to overload the function where the zoom range is changed, using the following incredibly hacky code:

var zoomRangeModifier = googleMap.__proto__.__proto__.__proto__;
var originalSetFunc = zoomRangeModifier.set;
var hijackedSetFunc = function(name, value) {
    if (name === 'maxZoom') { // Old API: name === 'zoomRange'
        value = 23;           // Old API: value.max = 23;
    }
    originalSetFunc.call(this, name, value);
};
zoomRangeModifier.set = hijackedSetFunc;
4
  • 5
    Google seems to have changed some of their underlying code (as of Jan 2019), so instead of this block if (a === 'zoomRange') { b.max = 23; } it should now be if (a === 'maxZoom') { b = 23; }
    – dallinski
    Feb 20, 2019 at 18:44
  • 1
    @dallinski thank you for this. Have saved me a lot of time. May 16, 2019 at 12:37
  • 1
    I edited the answer to work with the latest Google Maps JS. Hope you don't mind. Basically, you just need to use maxZoom now and that parameter is an integer. Feel free to roll back if you prefer your previous answer. In that case, please ping me and I will just add a new answer with the changes. :-)
    – Peque
    May 11, 2021 at 18:23
  • 1
    @Peque Thanks for taking the time to update! I added comments to your code to indicate how this was done in older versions of Google Maps, in case some users still require that information.
    – Jeff G
    May 12, 2021 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.