Quick Google Maps API question: How do you lock zoom levels to compare two regions at identical scale ratios?
The goal is to display different geographic areas with consistent screen-space-to-kilometer mapping. This means setting absolute zoom values rather than auto-fit bounds.
For Google Maps JavaScript API:
- Use map.setZoom(level) where level is an integer (0-22)
- Zoom 1 = world view, each increment doubles resolution
- Combine with map.setCenter({lat, lng}) for precise positioning
For comparing regions:
1. Calculate desired scale based on area size
2. Lock both map instances to same zoom integer
3. Adjust center coordinates to frame your regions
The tricky part: Google Maps uses Web Mercator projection, so pixel-to-km ratio varies by latitude. At zoom level Z, ground resolution at equator is ~156543.03 / 2^Z meters per pixel. For accurate comparisons at different latitudes, you need to account for cos(latitude) distortion.
If you're doing this in the UI without code, you can manually set zoom via URL parameters: ?z=12 or use the zoom slider while holding Shift to prevent auto-adjustment on pan.