I've got around 10 KML layers (around 2-4mb in size) and the user can
toggle them on/off.
I want to only load them if the user requests them, as otherwise
initializing each layer adds about 1 second to my page load times.
For instance, I have an election 2008 layer (Obama vote by county).
I've been initializing the GGeoXml object outside of the toggle
function, so that it can be toggled on/off. When I've tried
initializing inside the toggle function, it doesn't get recognized.
This is what I'm doing currently which is too slow (because it
initializes the kml layer whether or not the user needs it):
var toggleStateElection=0;
var geoXmlElection=new GGeoXml("http://www.energyjustice.net/map/kml/
ecounties-out.kmz");
function toggleElection()
{
if (toggleStateElection == 1) {
map.removeOverlay(geoXmlElection);
toggleStateElection = 0;
} else {
map.addOverlay(geoXmlElection);
toggleStateElection = 1;
}
}
If I try moving the
var geoXmlElection=new GGeoXml("http://www.energyjustice.net/map/kml/
ecounties-out.kmz");
line into the function (before the "if" statement) it will add it, but
not remove it. I don't want to have to remove all my overlays just to
remove this one.
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" 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-api?hl=en.