Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何解析文件geoxml3中的字符串?_Javascript_Jquery_Parsing_Xml Parsing_Geoxml3 - Fatal编程技术网

Javascript 如何解析文件geoxml3中的字符串?

Javascript 如何解析文件geoxml3中的字符串?,javascript,jquery,parsing,xml-parsing,geoxml3,Javascript,Jquery,Parsing,Xml Parsing,Geoxml3,我要分析此文件: 使用geoxml3 我通过代理下载这个文件,但我不知道如何解析字符串 例如,我想分析一个字符串: <name> ..... </name> <description>....</description> 。。。。。 .... 你能帮我吗 使用[geoxml3]解析字符串(包含KML)(https://github.com/geocodezip/geoxml3),使用解析器的.parseKmlString方法 map = ne

我要分析此文件: 使用
geoxml3

我通过代理下载这个文件,但我不知道如何解析字符串

例如,我想分析一个字符串:

<name> ..... </name> 
<description>....</description>
。。。。。
....
你能帮我吗

使用
[geoxml3]解析字符串(包含KML)(https://github.com/geocodezip/geoxml3)
,使用解析器的
.parseKmlString
方法

map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
geoXml = new geoXML3.parser({
  map: map,
  singleInfoWindow: true
});
geoXml.parseKmlString(kmlData); // kmlData contains a string containing valid KML

代码片段:

var geoxml=null;
函数初始化(){
var mylatng=newgoogle.maps.LatLng(39.397,-100.644);
变量myOptions={
缩放:5,
中心:myLatlng,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById('map\u canvas'),myOptions);
geoXml=新的geoXML3.parser({
地图:地图,
singleInfoWindow:true
});
parseKmlString(kmlData);
}
google.maps.event.addDomListener(窗口“加载”,初始化);
var kmlData='EMSC-最近两周全球地震2017年12-601ML 2.3-南加州2.3-南加州
2017-12-06 16:37:55.1 UTC


/>]]>#胭脂0.25]>#胭脂0.25]>#胭脂0.5]>#胭脂0.5]>#胭脂0.5]>#胭脂0.375]>#vert0.5]>#胭脂0.25]>#胭脂0.625绝对120.3089,-10.5510120.3089-10.5511000000https://static2.emsc.eu/Images/evt/c8-rouge.png0
$[说明]]>https://static2.emsc.eu/Images/evt/c8-rouge.png1
$[说明]]]>https://static3.emsc.eu/Images/evt/c8-jaune.png0
$[说明]]>https://static3.emsc.eu/Images/evt/c8-jaune.png1
$[说明]]>https://static1.emsc.eu/Images/evt/c8-vert.png0
$[说明]]>https://static1.emsc.eu/Images/evt/c8-vert.png1
$[说明]]>https://static2.emsc.eu/Images/evt/c8-bleu.png0
$[说明]]]>https://static2.emsc.eu/Images/evt/c8-bleu.png1
$[说明]]>https://static3.emsc.eu/Images/evt/c8-violet.png0
$[说明]]>https://static3.emsc.eu/Images/evt/c8-violet.png1
$[说明]]]>正常#非活动#红色高亮#活动#红色高亮#非活动#黄色高亮#活动#黄色高亮#非活动#红色高亮#非活动#黑色高亮#非正常#非活动#紫色高亮#活动ffffhttps://static1.emsc.eu/Images/legendge.pngEMSC 注销ffffhttps://static2.emsc.eu/Images/logoge.png';
html,
身体,
#地图画布{
身高:100%;
宽度:100%;
边际:0px;
填充:0px
}