Limiting Google Map Zoom Per Block

The way we handled the Google Map zooming issue was on a per page/block basis, for a couple reasons. The first being we didn't want to just generically do this across all pages, since in many cases (e.g. admin pages) it makes sense to want to be able to have full zoom support.

The other reason was more related to the timing of when we wanted the zoom limitation to be effective. If you do it too early in the process the "map" would not be initialized and available to override yet, and there were also cases where we needed it to happen after a form postback (e.g. group search results).

So this is what we settled on: We placed the following javascript in the post-html section of the block properties for any page/block that we wanted to restrict the map zooming for:

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function (s, e) {
map.setOptions({minZoom:7, maxZoom:12});

By attaching it to the end Request of the Page Request Manager of the Web Form we ensured that this code would still trigger after a PostBack, which was really the main challenge for us. But once you have access to the "map" variable late enough in the page life cycle (e.g. post-html) it's pretty trivial to use set Options to change any of the map properties.