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) // 加载至当前地图
相关推荐
智商不够_熬夜来凑3 分钟前
【Picker】单选多选
前端·javascript·vue.js
米饭不加菜40 分钟前
Typora 原生流程图语法完全指南(Flowchart.js)
前端·javascript·流程图
scan7241 小时前
langgraphy条件边
前端·javascript·html
冰小忆1 小时前
类变量在继承场景下的初始化规则是怎样的?
java·前端·数据库
YAwu112 小时前
JavaScript this 底层机制剖析
前端·javascript
xiaobobo33302 小时前
vscode+clangd打开头文件发现某些标识符不识别为“白色”语言模型识别为C++
vscode·识别头文件错误·标识符为白色·语言模型识别错误
你好潘先生2 小时前
让 AI 任务不丢进度:YeeroAI 后台续跑与全局快捷操作实践
前端·人工智能·后端
小KK_2 小时前
写给前端小白:我终于搞懂了JS原型和原型链
前端·javascript
烂人文2 小时前
Codex 走中转站后,手机也能远程控制,Free 账号也能用
前端