I am trying to display a kml file in a Google Map. I found two
methods of doing this. One looks like this:
//Method 1, this works, but I can't get it to zoom to the kml since I
don't know the lat long of the kml file.
var map = new GMap2(document.getElementById('GMAP'));
var geoXML = new GGeoXml("http://www.usahas.com/ge/kml/
No_BAM/" + sArea + ".kml")
//without the following line, I get a blank map
//map.setCenter(new GLatLng(34.019968,-118.289988), 17);
map.setMapType(G_HYBRID_MAP);
map.addControl(new GLargeMapControl());
map.addControl(new GScaleControl());
map.addControl(new GMapTypeControl());
map.addOverlay(geoXML);
That works with the map.setCenter line of code, but that isn't where I
want it to center. I want it to center on the kml file.
The other method looks like this:
//Method 2
var myOptions = {
zoom: 11,
mapTypeId: google.maps.MapTypeId.HYBRID
}
var map = new google.maps.Map(document.getElementById("GMAP"),
myOptions);
var kmlLayer = new google.maps.KmlLayer("http://www.usahas.com/
ge/kml/No_BAM/" + sArea + ".kml");
kmlLayer.setMap(map);
Method 2 centers on the kml, but it doesn't show all of the kml for
some reason.
--
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.