On Jul 9, 3:46 pm, Joseph Elfelt <[email protected]> wrote:
> Alas, I have not been able to figure out how to do these two things
> with KML files:
>
> A. When the map first appears on the user's screen, then display a
> KML file and let the API automatically set the map center and zoom
This seems to work for one kml file:
google.maps.event.addListener(ctaLayer, "metadata_changed" ,
function() {
map.fitBounds(ctaLayer.getDefaultViewport());
});
Since you haven't provided a link to your map, I don't know if it will
work for your code structure and I don't know that the
"metadata_changed" event is the best way to tell that the kmllayer has
loaded, I don't see a complete list of the available events in the
documentation. Maybe one of the google engineers can shed some light
on where those would be documented.
> B. As the user toggles the KML on/off, preserve the viewport
>
> Below is Google's KML demo map to which I added
> preserveViewport:true
> Adding this setting is the key to doing item 'B'.
>
> However, the initial appearance of the map (item 'A') uses the zoom
> setting in the options and as a result only part of the KML data is on
> the map. When I tried deleting the zoom setting in the options, then
> I got a blank map.
I believe the initial zoom is needed to "initialize" the map.
Although the documentation isn't very clear about what is required to
initialize the map.
-- Larry
>
> http://www.mappingsupport.com/forum_post/preserveViewport_kml_10.html
>
> I know how to toggle the KML on/off.
>
> Any ideas for how I can get all the KML to appear on the map when it
> first appears on the screen?
--
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.