本文介绍了使用Geoxml3将kml extendeddata加载到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,Geoxml3有一个内置的功能可以将kml extendeddata 加载到变量中(源代码见下文),但我无法找到解析后访问这些变量的方式。有谁知道该怎么做?谢谢,欢呼声。



(kmz分支的geoxml3.js的第544行):

  //将扩展数据添加到变量
var extDataNodes = node.getElementsByTagName('ExtendedData');
if(!! extDataNodes&& extDataNodes.length> 0){
var dataNodes = extDataNodes [0] .getElementsByTagName('Data');
for(var d = 0; 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;
}
}


解决方案

kmz分支版本的geoxml3,扩展数据存储在placemark.vars.val中。bb
$ b $ $ p $ name:Alvarães
percentntil:29.8
total:1699



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


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

这篇关于使用Geoxml3将kml extendeddata加载到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 06:18