4
votes

I do have a strange Problem with Google Maps API and a KML file.

When i initialize the Map with KML, everything works like charm. Now my problem: After zooming into the map (zoom Level 10) the KML Layer inverts.

Here is the example:

var settings,map,marker,infowindow,consultant_fname,consultant_lname,consultant_zip,consultant_city,mapOptions;
var markers = [];


$(document).ready(function(){
            mapOptions = {
				zoom: 8,
				center: new google.maps.LatLng(47.643186, 13.760376),
				scrollwheel: false,
				mapTypeControl: false,
				zoomControl: true,
				zoomControlOptions: {
					style: google.maps.ZoomControlStyle.SMALL,
					position: google.maps.ControlPosition.RIGHT_TOP
				},
				scaleControl: true,
				streetViewControl: false,
				panControl:true,
				panControlOptions : {
					position: google.maps.ControlPosition.RIGHT_TOP
				},
			};

			map = new google.maps.Map(document.getElementById('gmap'),mapOptions);
    
            var ctaLayer = new google.maps.KmlLayer('https://www.creditnet.at/austria_3.kml',{
				preserveViewport: true,
				suppressInfoWindows: true,
				map: map,
			});
			ctaLayer.setMap(map);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<div id="gmap" style="width:700px;height:700px;"></div>

Hopefully anyone can help me.

Regards M.

1
Please file a bug here: code.google.com/p/gmaps-api-issues/issues/…. Be sure to include all the relevant information. - Kay_N

1 Answers

2
votes

Seems like a bug in the KML renderer.

As a workaround, you could use a third party KML parser (like geoxml3 or geoxml-v3), geoxml3 doesn't seem to have that artifact:

Example using geoxml3 (and a slightly modified KML to cover the whole world)

Note that for complex KML the tiled based rendering of KmlLayer will be more efficient and you may run into performance issues with the 3rd party parsers.