|本文共629字,阅读约需2分钟
1
项目展示
2
开发准备
3
项目代码
<script type="text/javascript">
window._AMapSecurityConfig = {
securityJsCode:'您申请的安全密钥',
}
</script>
<script type="text/javascript" lay-src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
fetch("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson")
.then(function (response) {
return response.json();
})
.then(function (data) {
// 转换数据
heatmapData = data.features.map(function (feature) {
return {
lng: feature.geometry.coordinates[0],
lat: feature.geometry.coordinates[1],
count: feature.properties.mag
}
});
var heatmap;
map.plugin(["AMap.HeatMap"], function () {
//初始化heatmap对象
heatmap = new AMap.HeatMap(map, {
radius: 13, //给定半径
opacity: [0, 0.8],
max:10
});
//设置数据集:该数据为北京部分“公园”数据
heatmap.setDataSet({
data: heatmapData,
});
});
});
4
代码获取