Hi, I've been trying to figure out a solution to this problem. Basically, I have a KML which contains one and only one placemark. I'd like to generate a map where the placemark is in the center of the map and the zoom is around level 15 or so. I have my code running here:
http://pascual.ph/findlaw/maps.html My javascript is as follows: <script type="text/javascript"> function initialize() { var maplatlng = new google.maps.LatLng(40.65, -73.95); var mapoptions = { zoom : 15, center : maplatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("gmap"), mapoptions); var kmlLayer = new google.maps.KmlLayer("http:// flimages.cdn.findlaw.com/kml/2754111.kml", { suppressInfoWindows : true }); kmlLayer.setMap(map); map.setZoom(15); google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) { alert("zoom = " + map.getZoom()); map.setZoom(15); }); } </script> Basically, to start with, I'm just choosing any old latlng with the hopes that the KmlLayer object will center to the only placemark and place the map around it. It does this, however, the zoom level is automatically set to level 20 (I can tell as I've added an event to the placemark so I can see what the zoom is and then set it as a test). I try to use map.setZoom(15), but this doesn't seem to work. My guess is that the KmlLayer object hasn't finished doing its thing before the map.setZoom(15) comes around. Is there a callback or something so I can set the zoom level after the kmlLayer is done loading? A secondary question: is there a way to "parse" the kml to get the "center/boundary" so I don't have to create the map with some randomly chosen latlng and then rely on the KmlLayer to really center it for me? Thanks for any help. Mark -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
