I am using geoxml3 from local machine to load kml. However the default view center is changing once kml is loaded. I did try adding line "preserveViewport: true" but still I get full view of kml after loading. any suggestion to stop this.
Here is my code
<html>
<head>
<title>Google Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript" src="geoxml3-master/polys/geoxml3.js"></script>
<script type="text/javascript" src="geoxml3-master/ProjectedOverlay.js"></script>
<script>
var myCenter=new google.maps.LatLng( 13.751768, 100.537606);
var map;
var marker;
var mapProp;
function initialize()
{
mapProp = {
center:myCenter,
zoom:17,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map=new google.maps.Map(document.getElementById("map"),mapProp);
var parser = new geoXML3.parser({
suppressInfoWindows: true,
map: map,
preserveViewport: true
});
parser.parse('test.kml');
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div style="height:100%; width:100%;">
<div id="map"></div>
</div>
</body>
For geoxml3, the equivalent of
preserveViewport
iszoom
. Set it to true (the default) to automatically zoom to fit the KML, set it to false to disable that functionality.code snippet: