gpt4 book ai didi

javascript - 显示来自 USGS 地震 JSON 数据的元数据

转载 作者:行者123 更新时间:2023-11-30 14:58:03 25 4
gpt4 key购买 nike

-我正在创建一个实时地震 map 网站 www.livehazards.com

-我在拉。我的数据来自 UGSG 网站(GeoJson 格式)。 "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_month.geojson "

特征的特征集合/元数据是{类型:“特征集合”,元数据:{生成:长整数,网址:字符串,标题:字符串,接口(interface):字符串,计数:整数状态:整数},

  • 我想在边栏中显示/打印计数整数,但不知道要使用什么代码来执行此操作。

有人帮忙吗?

最佳答案

在这里,我准备了一个示例,其中我将示例 5 特征对象粘贴到 JSON 字符串(已缩小)中并获得结果。您可以申请相同的。

<!DOCTYPE html>
<html>
<body>
<script>
// JSON.parse(<JSON String>); // Json string is minified
var obj = JSON.parse('{"type":"FeatureCollection","metadata":{"generated":1509005451000,"url":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_month.geojson","title":"USGS Magnitude 1.0+ Earthquakes, Past Month","status":200,"api":"1.5.8","count":5681},"features":[{"type":"Feature","properties":{"mag":0.99,"place":"2km SE of The Geysers, California","time":1509005085910,"updated":1509005181998,"tz":-480,"url":"https://earthquake.usgs.gov/earthquakes/eventpage/nc72914101","detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/nc72914101.geojson","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"automatic","tsunami":0,"sig":15,"net":"nc","code":"72914101","ids":",nc72914101,","sources":",nc,","types":",geoserve,nearby-cities,origin,phase-data,","nst":7,"dmin":0.01315,"rms":0.01,"gap":159,"magType":"md","type":"earthquake","title":"M 1.0 - 2km SE of The Geysers, California"},"geometry":{"type":"Point","coordinates":[-122.7351685,38.7636681,1.04]},"id":"nc72914101"},{"type":"Feature","properties":{"mag":1.01,"place":"14km ESE of Mammoth Lakes, California","time":1508996258570,"updated":1509000963664,"tz":-480,"url":"https://earthquake.usgs.gov/earthquakes/eventpage/nc72914056","detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/nc72914056.geojson","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"automatic","tsunami":0,"sig":16,"net":"nc","code":"72914056","ids":",nc72914056,","sources":",nc,","types":",geoserve,nearby-cities,origin,phase-data,scitech-link,","nst":8,"dmin":0.01545,"rms":0.03,"gap":96,"magType":"md","type":"earthquake","title":"M 1.0 - 14km ESE of Mammoth Lakes, California"},"geometry":{"type":"Point","coordinates":[-118.8184967,37.6030006,4.35]},"id":"nc72914056"},{"type":"Feature","properties":{"mag":1.6,"place":"62km WNW of Beatty, Nevada","time":1508993349830,"updated":1508993549009,"tz":-480,"url":"https://earthquake.usgs.gov/earthquakes/eventpage/nn00610589","detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/nn00610589.geojson","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"automatic","tsunami":0,"sig":39,"net":"nn","code":"00610589","ids":",nn00610589,","sources":",nn,","types":",geoserve,origin,phase-data,","nst":31,"dmin":0.195,"rms":null,"gap":136.69,"magType":"ml","type":"earthquake","title":"M 1.6 - 62km WNW of Beatty, Nevada"},"geometry":{"type":"Point","coordinates":[-117.4003,37.13,5.5]},"id":"nn00610589"},{"type":"Feature","properties":{"mag":2.03,"place":"1km ESE of Pahala, Hawaii","time":1508989731730,"updated":1508989927780,"tz":-600,"url":"https://earthquake.usgs.gov/earthquakes/eventpage/hv61956446","detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/hv61956446.geojson","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"automatic","tsunami":0,"sig":63,"net":"hv","code":"61956446","ids":",hv61956446,","sources":",hv,","types":",geoserve,origin,phase-data,","nst":42,"dmin":0.04174,"rms":0.19,"gap":105,"magType":"md","type":"earthquake","title":"M 2.0 - 1km ESE of Pahala, Hawaii"},"geometry":{"type":"Point","coordinates":[-155.466507,19.1971664,33.47]},"id":"hv61956446"},{"type":"Feature","properties":{"mag":2.07,"place":"24km ENE of Soledad, California","time":1508987976180,"updated":1508999403619,"tz":-480,"url":"https://earthquake.usgs.gov/earthquakes/eventpage/nc72914021","detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/nc72914021.geojson","felt":null,"cdi":null,"mmi":null,"alert":null,"status":"automatic","tsunami":0,"sig":66,"net":"nc","code":"72914021","ids":",nc72914021,","sources":",nc,","types":",geoserve,nearby-cities,origin,phase-data,scitech-link,","nst":18,"dmin":0.06662,"rms":0.05,"gap":130,"magType":"md","type":"earthquake","title":"M 2.1 - 24km ENE of Soledad, California"},"geometry":{"type":"Point","coordinates":[-121.0631638,36.4811668,3.99]},"id":"nc72914021"}],"bbox":[-179.9476,-61.9084,-2.93,179.9778,71.4011,614.26]}');

alert(obj.features.length);
</script>

</body>
</html>

希望,它的作品。谢谢:)

关于javascript - 显示来自 USGS 地震 JSON 数据的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46948944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com