3.0 KML – To zoom or not to zoom

By default, if you add a kml layer using the Google Maps API, it will automatically zoom to the extent of the kml objects, regardless of what zoom level or center latitude longitude you have specified. While this might be a desired behavior, it is more than likely that you want to control the zoom level and location of the map yourself. To do so, you need to set the optional object parameter for “preserveViewport” to “true” { preserveViewport: true }, as shown below in line 5.

You can find the documentation for this in the Google Maps API reference site here.

Leave a Reply