0
votes

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?

1

1 Answers

1
votes

Your KML file contains a bad point:

<Placemark>
    <name>Dr. Sibbald</name>
    <description><![CDATA[<br><b>Address:</b> Applewood Shopping Ctre, Suite 210, 1077 N. Service Rd<br><b>City:</b> Mississauga<br><b>Postal Code:</b> L5R 2X5<br><b>Telephone:</b> (905)273-9009<br><b>Sponsoring Club:</b> Mississauga Credit Valley Lions Club]]></description>
    <styleUrl>#icon-503-DB4436</styleUrl>
    <Point>
        <coordinates>-3.0,90.0,0.0</coordinates>
    </Point>
    <!-- ... -->
</Placemark>

It located at the North Pole.