KML Layers - Stack Order Wierdness.

213 views
Skip to first unread message

Thomas

unread,
Mar 7, 2011, 3:02:08 PM3/7/11
to Google Maps JavaScript API v3
So, I'm having a real dilly of a pickle of a problem getting KML
layers to stack properly.

I have a varied group of overlays which I want to render: Polygons,
Polylines and Markers.

I hunted through the groups and found this -
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/d141c913badec13a
- which outlines the way to sequentially load your KML and supposedly
have them stack properly.

Unfortunately, this doesn't appear to be working. Would be great if it
did! I am using the "metadata_changed" toggle.

I have also read that there appears to be a separate stack for each of
the overlay types. I don't know if that is true, but for the sake of
argument let's say two KML Polygons layers.

Now, here's where the odd parts come in:
Regardless of the order in which I add the KML layers to the maps the
stack order is always the same.

For the life of me, I can't figure out why cherry faced rooster
plucking files order themselves this way (FYI this includes all of the
types of overlays)

I attempted to change the altitudeMode attribute in the KML files to
see if it played a roll: no dice. I've examined the styles line-by-
line and they are identical between all the files.

Any idea what governs the stack order for KML layers?

Thanks in advance all.

geoco...@gmail.com

unread,
Mar 7, 2011, 3:35:38 PM3/7/11
to Google Maps JavaScript API v3
On Mar 7, 12:02 pm, Thomas <thomas.bax...@gmail.com> wrote:
> So, I'm having a real dilly of a pickle of a problem getting KML
> layers to stack properly.
>
> I have a varied group of overlays which I want to render: Polygons,
> Polylines and Markers.
>
> I hunted through the groups and found this
> -http://groups.google.com/group/google-maps-js-api-v3/browse_thread/th...
> - which outlines the way to sequentially load your KML and supposedly
> have them stack properly.
>
> Unfortunately, this doesn't appear to be working. Would be great if it
> did! I am using the "metadata_changed" toggle.
>
> I have also read that there appears to be a separate stack for each of
> the overlay types. I don't know if that is true, but for the sake of
> argument let's say two KML Polygons layers.
>
> Now, here's where the odd parts come in:
> Regardless of the order in which I add the KML layers to the maps the
> stack order is always the same.
>
> For the life of me, I can't figure out why cherry faced rooster
> plucking files order themselves this way (FYI this includes all of the
> types of overlays)
>
> I attempted to change the altitudeMode attribute in the KML files to
> see if it played a roll: no dice. I've examined the styles line-by-
> line and they are identical between all the files.

Would you have an example that exhibits the problem?

-- Larry

Thomas Baxter

unread,
Mar 7, 2011, 4:21:42 PM3/7/11
to google-map...@googlegroups.com, geoco...@gmail.com
The following links have two different orders (the order by which they appear in the orange sidebar is the order in which they were loaded)
http://pmlf.net/gmaps/?ordering=1
http://pmlf.net/gmaps/?ordering=2

and here's the javascript file:
http://pmlf.net/gmaps/js/locator_version2.js

In the first link the blue marker should be on top; redlines on top of the green overlay; green overlay on top of the yellow overlay.

In the second link the ordering should be: yellow overtop of everything, the blue marker underneath that, the green overlay, then the red lines.




Now, when I was preparing this and doing some more testing, this started to work... sporadically. At first I though that the problem had vanished, but no: merely more Wierdness.

It seems that everytime you reload the page, the layers have a chance to order themselves properly, or completely change their orders altogether. The is truly odd.

Hopefully I am just making a glaring oversight.


FYI Layer descriptions:
Roads_ST = red lines
NaturalAreas_SimplifyPolygon = small areas, sorta green
ConservationBlueprints_sm = large area, sorta yellow
geo = the single blue pin




Thanks for your time



--
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.


geoco...@gmail.com

unread,
Mar 7, 2011, 5:19:45 PM3/7/11
to Google Maps JavaScript API v3
On Mar 7, 1:21 pm, Thomas Baxter <thomas.bax...@gmail.com> wrote:
> The following links have two different orders (the order by which they
> appear in the orange sidebar is the order in which they were loaded)

http://pmlf.net/gmaps/?ordering=1

http://pmlf.net/gmaps/?ordering=2

Neither of those maps loads correctly in IE(6), they seem to have the
"zero size" div problem.

In fact they look like they are invalid html (missing the closing tags
for body and html
http://validator.w3.org/check?uri=http%3A%2F%2Fpmlf.net%2Fgmaps%2F%3Fordering%3D1&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.2

http://validator.w3.org/check?uri=http%3A%2F%2Fpmlf.net%2Fgmaps%2F%3Fordering%3D2&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.2

I will look at them when I get to a real browser, but I can't see the
problem the way they are.

-- Larry

>
> and here's the javascript file:http://pmlf.net/gmaps/js/locator_version2.js
>
> In the first link the blue marker should be on top; redlines on top of the
> green overlay; green overlay on top of the yellow overlay.
>
> In the second link the ordering should be: yellow overtop of everything, the
> blue marker underneath that, the green overlay, then the red lines.
>
> Now, when I was preparing this and doing some more testing, this started to
> work... sporadically. At first I though that the problem had vanished, but
> no: merely more Wierdness.
>
> It seems that everytime you reload the page, the layers have a chance to
> order themselves properly, or completely change their orders altogether. The
> is truly odd.
>
> Hopefully I am just making a glaring oversight.
>
> FYI Layer descriptions:
> Roads_ST = red lines
> NaturalAreas_SimplifyPolygon = small areas, sorta green
> ConservationBlueprints_sm = large area, sorta yellow
> geo = the single blue pin
>
> Thanks for your time
>
> On Mon, Mar 7, 2011 at 3:35 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.- Hide quoted text -
>
> - Show quoted text -

Thomas Baxter

unread,
Mar 7, 2011, 6:08:52 PM3/7/11
to google-map...@googlegroups.com, geoco...@gmail.com
IE6 is below my support level, and this is (obviously) initial functional dev.

Regardless, I've closed off the doc.

geoco...@gmail.com

unread,
Mar 7, 2011, 6:29:11 PM3/7/11
to Google Maps JavaScript API v3
On Mar 7, 3:08 pm, Thomas Baxter <thomas.bax...@gmail.com> wrote:
> IE6 is below my support level, and this is (obviously) initial functional
> dev.

Understood. It just means I can't see the problem now.

>
> Regardless, I've closed off the doc.

I see that. The map still isn't being given a size though...

-- Larry

>
> On Mon, Mar 7, 2011 at 5:19 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
>
>
> > On Mar 7, 1:21 pm, Thomas Baxter <thomas.bax...@gmail.com> wrote:
> > > The following links have two different orders (the order by which they
> > > appear in the orange sidebar is the order in which they were loaded)
>
> >http://pmlf.net/gmaps/?ordering=1
>
> >http://pmlf.net/gmaps/?ordering=2
>
> > Neither of those maps loads correctly in IE(6), they seem to have the
> > "zero size" div problem.
>
> > In fact they look like they are invalid html (missing the closing tags
> > for body and html
>
> >http://validator.w3.org/check?uri=http%3A%2F%2Fpmlf.net%2Fgmaps%2F%3F...
>
> >http://validator.w3.org/check?uri=http%3A%2F%2Fpmlf.net%2Fgmaps%2F%3F...

geoco...@gmail.com

unread,
Mar 7, 2011, 6:38:30 PM3/7/11
to Google Maps JavaScript API v3
On Mar 7, 1:21 pm, Thomas Baxter <thomas.bax...@gmail.com> wrote:
> The following links have two different orders (the order by which they
> appear in the orange sidebar is the order in which they were loaded)http://pmlf.net/gmaps/?ordering=1http://pmlf.net/gmaps/?ordering=2
>
> and here's the javascript file:http://pmlf.net/gmaps/js/locator_version2.js
>
> In the first link the blue marker should be on top; redlines on top of the
> green overlay; green overlay on top of the yellow overlay.
>
> In the second link the ordering should be: yellow overtop of everything, the
> blue marker underneath that, the green overlay, then the red lines.
>
> Now, when I was preparing this and doing some more testing, this started to
> work... sporadically. At first I though that the problem had vanished, but
> no: merely more Wierdness.
>
> It seems that everytime you reload the page, the layers have a chance to
> order themselves properly, or completely change their orders altogether. The
> is truly odd.

My suspicion is that the order depends on the order the results arrive
back from google's server, as the requests are asynchronous and when
the result comes back depends on network conditions, server load,
complexity of the kml and order requested; you may not be able to
control that very easily.

Toggling a layer seems to move it to the top of the stack. Perhaps
you can request the layers, then hide them all [.setMap(null)] and
show them [setMap(map)] in the order you want them to appear.

-- Larry

>
> Hopefully I am just making a glaring oversight.
>
> FYI Layer descriptions:
> Roads_ST = red lines
> NaturalAreas_SimplifyPolygon = small areas, sorta green
> ConservationBlueprints_sm = large area, sorta yellow
> geo = the single blue pin
>
> Thanks for your time
>
> On Mon, Mar 7, 2011 at 3:35 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:

Thomas Baxter

unread,
Mar 7, 2011, 7:23:02 PM3/7/11
to google-map...@googlegroups.com, geoco...@gmail.com
You're totally right about the show/hide solution.
I think I'll see about loading each layer as hidden, then showing them in the desired order.
Would actually be a nicer way to load data as well, instead of the current "blink" that goes on when each layer is loaded.

Thanks for picking that up though, I totally missed it. I'll post a follow up with full code once its done.

geoco...@gmail.com

unread,
Mar 7, 2011, 8:09:06 PM3/7/11
to Google Maps JavaScript API v3
On Mar 7, 4:23 pm, Thomas Baxter <thomas.bax...@gmail.com> wrote:
> You're totally right about the show/hide solution.
> I think I'll see about loading each layer as hidden, then showing them in
> the desired order.
> Would actually be a nicer way to load data as well, instead of the current
> "blink" that goes on when each layer is loaded.
>
> Thanks for picking that up though, I totally missed it. I'll post a follow
> up with full code once its done.

BTW - I don't see your "blue marker", I don't think the "files/
marker_icon.png" reference will work, I think you need an absolute URL
there.

-- Larry

>
> On Mon, Mar 7, 2011 at 6:38 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
>
>

Thomas Baxter

unread,
Mar 9, 2011, 1:00:25 PM3/9/11
to google-map...@googlegroups.com
Thanks.
Shows for me, and I am still waiting on designs for this, so once that's done I'll be building a KML parser to update the PolyStyles and image references.

Cyril Sauvenay

unread,
May 26, 2011, 12:07:03 PM5/26/11
to google-map...@googlegroups.com
Hi
I was looking everywhere in the wild wild web to understand that issue; I have exactly the same issue. I would like a kml to display first lines, markers, and after groundoverlays. If you find any way to do so (even with more than one kml) I would be very happy if you were able to let us know!
Thanks!
Cyril

Rossko

unread,
May 26, 2011, 3:17:31 PM5/26/11
to Google Maps JavaScript API v3
> have exactly the same issue. I would like a kml to display first lines,
> markers, and after groundoverlays. If you find any way to do so (even with
> more than one kml) I would be very happy if you were able to let us know!
> Thanks!
> Cyril

Look up a few posts for the answer

Cyril Sauvenay

unread,
May 27, 2011, 10:50:12 AM5/27/11
to Google Maps JavaScript API v3
Thank you. That's an idea to try. Some people tell it does work, some
other tell it does not. Let's try!

Cyril Sauvenay

unread,
May 27, 2011, 12:35:22 PM5/27/11
to Google Maps JavaScript API v3
Well, it seems not to work.

This is what I wrote:

var ctaLayer = new google.maps.KmlLayer('http://www.l2com.fr/
googlemap/testpictoslignes.kml');
ctaLayer.setMap(null);

var leoLayer = new google.maps.KmlLayer('http://www.l2com.fr/
googlemap/testgroundoverlay.kml');
leoLayer.setMap(null);

ctaLayer.setMap(map);
leoLayer.setMap(map);


But the "leolayer" is behind "ctalayer" ! (leolayer = groundoverlay ;
ctalayer = markers & lines ; they should be in the same map pane,
shouldn't they?)

Thanks!

Cy

Reply all
Reply to author
Forward
0 new messages