arcgis API for javascript 4.x GeoJSONLayer 加载方法

复制代码
1.引入GeoJSONLayer
import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer'
或者
require(["esri/layers/GeoJSONLayer"], function(GeoJSONLayer){ 
const geojsonlayer = new GeoJSONLayer({ 
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", copyright: "USGS Earthquakes" }); 
map.add(geojsonlayer); // adds the layer to the map 
});
复制代码
// create a geojson layer from geojson feature collection 
const geojson = { 
type: "FeatureCollection", 
features: [ 
{ 
type: "Feature", 
id: 1, 
eometry: { 
type: "Polygon", 
coordinates: [ 
[ 
[100.0, 0.0], 
[101.0, 0.0], 
[101.0, 1.0], 
[100.0, 1.0], 
[100.0, 0.0] 
] 
] 
}, 
properties: { 
type: "single", 
recordedDate: "2018-02-07T22:45:00-08:00" } 
} 
] 
}; 
// create a new blob from geojson featurecollection 
const blob = new Blob([JSON.stringify(geojson)], { 
type: "application/json" 
}); 
// URL reference to the blob 
const url = URL.createObjectURL(blob); 
// create new geojson layer using the blob url 
const layer = new GeoJSONLayer({ 
url 
});

this.map.add(layer) // 加载至当前地图
相关推荐
赵庆明老师1 小时前
Vben精讲:21-详解web-antd:tsconfig.json
前端·json·vim
wc881 小时前
微软EDGE浏览器功能学习
前端·学习·edge
TunerT_TQ1 小时前
Valhalla 静态工程审阅 #009|Continue 源码证据驱动评测【大厂开源基础设施特辑】
vscode·测试工具·开源·llm·github·jetbrains·ai编程助手
Csvn2 小时前
🎯 原生 `<dialog>` 元素:终于可以扔掉一半的自定义弹窗组件了?
前端
Csvn2 小时前
🎨 CSS @layer:用「层叠优先级」终结样式打架的世纪难题
前端
濮水大叔2 小时前
不必把 Vue3 写成“麻花”:从状态碎片到对象协作,重新理解 Zova 的前端心智模型
前端·typescript·vue3·ioc·tsx·zova
时时三省3 小时前
VScode 智能插件安装
ide·vscode·编辑器
Vuji3 小时前
MCP: 一条 tool 调用链路的旅程
前端·人工智能
万少4 小时前
DeepSeek-V4-Flash 正式版上线了,但这 3 个坑我帮你提前踩了
前端·javascript·后端
明月_清风4 小时前
🚀 Palantir Foundry 本体论实战:当 Ontology 从"知识图谱"进化为"企业操作系统"
前端·后端