2 KmlLayer

532 views
Skip to first unread message

john

unread,
Oct 25, 2010, 1:21:46 PM10/25/10
to Google Maps JavaScript API v3
I have a KmlLayer with many polygons in it (all polys are in blue).
http://209.35.190.130/kmltest/sg_a.html using http://209.35.190.130/kmltest/93_80.kml

I have another KmlLayer with 3 polygons (a subset of the above, in
red)
http://209.35.190.130/kmltest/sg_b.html http://209.35.190.130/kmltest/93_80_1.kml

My purpose is to make the subset of polygons in "a" to red. So I tried
to load the on after another. It worked last night but somehow it
stopped working when I got up in the morning.
http://209.35.190.130/kmltest/sg_ab.html

I then made a copy of 93_80_1.kml as 93_80_a.kml. And it worked again.
Refresh it. it stopped working again. So, I believe problem is the
cache. But it not my local cache because I cleared it.

James McGill

unread,
Oct 25, 2010, 1:28:50 PM10/25/10
to google-map...@googlegroups.com
Hi John,

Try waiting for the first (blue) layer to finish loading before adding the red layer. You can do this by listening to the metadata_changed event, for example.

Your current problem is that .setMap(map) is evaluated asynchronously for KMLLayer, so it is valid for the layers to be loaded in either order. Sometimes the blue layer will load first, and red will appear on top, other times it will be reversed. By waiting for the blue layer to load before adding the red layer, you can enforce an ordering.

Regards,
James


--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Chad Killingsworth

unread,
Oct 25, 2010, 2:30:48 PM10/25/10
to Google Maps JavaScript API v3
I could have sworn there was a feature request to let developers set a
relative z-index on KmlLayers. Not finding one, I created a new one
because this issue comes up way too often.

http://code.google.com/p/gmaps-api-issues/issues/detail?id=2804

Chad Killlingsworth
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> > .

john

unread,
Oct 27, 2010, 3:35:45 PM10/27/10
to Google Maps JavaScript API v3
Using James' suggestion. metadata_changed event worked for me.
Still, zIndex would be a better solution.
Also, I would to be able get access the element (Placemark) and change
the individual style).

Thanks.

John

On Oct 25, 1:30 pm, Chad Killingsworth
Reply all
Reply to author
Forward
0 new messages