Open GoogleCodeExporter opened 9 years ago
Have you looked at geoxml-v3?
http://code.google.com/p/geoxml-v3/
Lance has much better sidebar support in that (which is a port of his v2
version which is much more full featured)
I wasn't planning on doing any of that in geoxml3 itself.
Original comment by geocodezip
on 23 Mar 2012 at 3:10
Hi, didn't knew about the v3 library! thanks a lot!!!. I'll study it thoroughly
;)
The code I wrote it's not refered to sidebar support... it's only a patch to
allow loading of KMLs with <folder>...</folder> structures.
BTW. A little update to make it work on iPad/iPhone. Replace the "if" with this
one:
if( folder[i].nodeType == 1 && folder[i].nodeName != 'name' ) // &&
folder[i].constructor.name === 'Element'
Original comment by jrd...@gmail.com
on 26 Mar 2012 at 7:12
Do you have an example KML file that contains folders and doesn't work without
your change? And/or a link to a map that shows the issue?
Original comment by geocodezip
on 26 Mar 2012 at 12:04
The only thing I do to reproduce the problem is to open a KML in Google Earth
(appears in a folder) and save it clicking on the floder it creates.
If you can't reproduce it, tell me and I'll look for a good example.
Original comment by jrd...@gmail.com
on 2 Apr 2012 at 10:30
I don't use Google Earth and I'm not sure how that applies to geoxml3.
Original comment by geocodezip
on 2 Apr 2012 at 12:40
[deleted comment]
[deleted comment]
I am looking into your code as well and was interested in a sidebar. The
feature that is missing is that of Folder name, but since that is really a
parent of the Placemark I modified your js to include an array of parents to
each Placemark. This will allow grouping of the Placemarks into the logical
groups that may or may not be present in a KML. NOTE: if the KML doesn't have
Folder tags then the search for parent nodes will always only show one parent
(the first 'name' tag). Change is 8 lines of code.
//code show here
//the baseUrl is the first 'name' tag in the KML document
var baseUrl = geoXML3.nodeValue(responseXML.getElementsByTagName('name')[0]);
//start of your code
var placemarkNodes = responseXML.getElementsByTagName('Placemark');
for (pm = 0; pm < placemarkNodes.length; pm++) {
// Init the placemark object
node = placemarkNodes[pm];
//parent, grandparent etc root is always the baseUrl name
//get nodes parent
var pNode = node.parentNode;
//initialize parent array
var parent = [];
//add parent 'name' to array
parent[0] = geoXML3.nodeValue(pNode.getElementsByTagName('name')[0]);
//while first item in parent array isn't baseUrl continue
while (parent[0] !== baseUrlNode) {
//each time through get the parent of the parent
pNode = pNode.parentNode;
//add the parent 'name' to the front of the array parent.unshift(geoXML3.nodeValue(pNode.getElementsByTagName('name')[0]));
} //end search for nodes lineage
//your code again
//except new item in placemark of the above parent array
placemark = {
name: geoXML3.nodeValue(node.getElementsByTagName('name')[0]),
parent: parent,
description: geoXML3.nodeValue(node.getElementsByTagName('description')[0]),
styleUrl: geoXML3.nodeValue(node.getElementsByTagName('styleUrl')[0])
};
Original comment by davej...@yahoo.com
on 19 Jul 2014 at 8:10
Original issue reported on code.google.com by
jrd...@gmail.com
on 23 Mar 2012 at 11:18