Load kml extendeddata into variable with Geoxml3

為{幸葍}努か 提交于 2019-11-27 07:21:25

问题


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;
}
}

回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!