I have an existing map on a web page that is zoomed and centred properly using the following script segment: var mapOptions = { center: { lat: 43.57023, lng: -79.48676 }, zoom: 12 } map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
I then add the kml layer using: var myLayer = new google.maps.KmlLayer({ url: "" }); myLayer.setMap(map);
This has been working for the last year. However I had to update the kml file to include a wider area. The new kml file works but the new zoom and centre locations aren't being respected.
map = new google.maps.Map(document.getElementById("map-canvas"), {
center: { lat: 48.0, lng: -89.0 },
zoom: 4
});
Instead the map is zoomed out so I see 3 complete Earths plus a bit on each side and the centre is way above the North Pole. You can see the two different results at http://www.a711lions.ca/recycleforsight/locationmap.html and http://www.a711lions.ca/recycleforsight/locationmap2.html.
I have read that I can use a layer.preserveViewport setting to overcome this, but I'm trying to understand why it is even happening. AFAICT the points are all in Canada (they certainly don't show up in the triple-Earth view as being anywhere else) so why is the KML layer so huge?
Any ideas?