I understand that Geoxml3 has a built in feature to load kml extendeddata into variables (from its source code - see bellow), but I couldn't find the way to access those variables after parsing. Does anyone know how to do it? Thanks, cheers.
(line 544 of geoxml3.js of kmz branch):
// add extended data to variables
var extDataNodes = node.getElementsByTagName('ExtendedData');
if (!!extDataNodes && extDataNodes.length > 0) {
var dataNodes = extDataNodes[0].getElementsByTagName('Data');
for (var d = 0; d < dataNodes.length; d++) {
var dn = dataNodes[d];
var name = dn.getAttribute('name');
if (!name) continue;
var dName = geoXML3.nodeValue(dn.getElementsByTagName('displayName')[0], name);
var val = geoXML3.nodeValue(dn.getElementsByTagName('value')[0]);
placemark.vars.val[name] = val;
placemark.vars.display[name] = dName;
}
}
In the kmz branch version of geoxml3, the extended data is stored in placemark.vars.val
name: "Alvarães"
percentil: "29.8"
total: "1699"
So, this should work:
var contentString = '<div class="maptab">'+
'<h1>'+placemark.name+'</h1>'+
'fora da escola: '+placemark.vars.val.total+'<br>'
'percentual: '+placemark.vars.val.percentil+
'</div>';
polygonMouseover(placemark.polygon,contentString);
来源:https://stackoverflow.com/questions/21537680/load-kml-extendeddata-into-variable-with-geoxml3