How do I specify zoom level for google maps in a kml file or why is it that my zoom level gets over ridden when I load this file. My question is actually how do I control zoom of a map for the following link:
http://code.google.com/apis/maps/documentation/javascript/examples/layer-kml-features.html
By default, the map is centered and zoomed to the bounding box of the contents of the kml layer.
You can change the default behaviour with
preserveViewport
property ofgoogle.maps.KmlLayerOptions
object. If you set it totrue
the map isn't centered and zoomed.In the example, use:
If you want to center and zoom to the contents of the kml layer later, use:
EDIT:
If you want the map to be always centered (but not zoomed) when the kml layer is loaded, utilize
defaultviewport_changed
event of thegoogle.maps.KmlLayer
object. You have to set the map center to the center of the kml layer default viewport. The event is triggered when the contents of the kml layer are loaded and its default viewport is computed.