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) // 加载至当前地图
相关推荐
胡gh11 分钟前
css的臂膀,前端动效的利器,还是布局的“隐形陷阱”?
前端·css·html
灵感菇_19 分钟前
Flutter Riverpod 完整教程:从入门到实战
前端·flutter·ui·状态管理
用户214118326360224 分钟前
紧急修复!Dify CVE-2025-55182 高危漏洞,手把手教你升级避坑
前端
Vic101011 小时前
解决 Spring Security 在异步线程中用户信息丢失的问题
java·前端·spring
wordbaby1 小时前
Expo (React Native) 最佳实践:TanStack Query 深度集成指南
前端·react native
~无忧花开~1 小时前
Vue二级弹窗关闭错误解决指南
开发语言·前端·javascript·vue.js
软件技术NINI1 小时前
前端面试题:请描述一下你对盒模型的理解
前端
码事漫谈2 小时前
VS Code终端从入门到精通完全指南
前端·后端
wordbaby2 小时前
Expo (React Native) 本地存储全攻略:普通数据与敏感数据该存哪?
前端·react native
IOT那些事儿2 小时前
VSCode类软件(Trae、Cursor)占用C盘问题
ide·vscode·编辑器