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) // 加载至当前地图
相关推荐
e***U8205 分钟前
React Hooks性能优化
前端·react.js·前端框架
4***R2406 分钟前
React数据分析
前端·react.js·前端框架
X***E4637 分钟前
React课程
前端·react.js·前端框架
4***99747 分钟前
React音频处理案例
前端·react.js·音视频
1***815311 分钟前
React组件
前端·javascript·react.js
6***34926 分钟前
Vue混合现实案例
前端·vue.js·mr
p***434832 分钟前
Vue混合现实开发
前端·vue.js·mr
ArkPppp34 分钟前
大道至简-Shadcn/ui设计系统初体验(下):Theme与色彩系统实战
前端·前端框架
炒米233334 分钟前
通义千问Qwen3-Coder模型帮我总结的typescript笔记
前端
__花花世界40 分钟前
前端日常工作开发技巧汇总
前端·javascript·vue.js