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) // 加载至当前地图
相关推荐
Jet_closer_burning2 分钟前
css grid布局属性详解
前端·css·html
安冬的码畜日常17 分钟前
【CSS in Depth 2 精译_026】4.4 Flexbox 元素对齐、间距等细节处理(上)
前端·css·css3·html5·flexbox·css布局
本郡主是喵18 分钟前
由于安装nvm 引发的vue : 无法将“vue”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
前端·javascript·vue.js
京城五22 分钟前
text-overflow:ellipsis 不生效的情况解决办法
前端·css·html
前进别停留1 小时前
javaWeb三剑客:html,css
前端·css·html
这家伙是个好家伙1 小时前
GitHub Copilot Issue in Visual Studio Code “Status Ready (disabled)“
vscode·github·copilot·issue
Mzp风可名喜欢2 小时前
JS手写实现深拷贝
前端·javascript
yiyiy111yiy2 小时前
关于Harmony的学习
前端·javascript·学习·原型模式
DYS_000012 小时前
哨兵机制Sentinel
linux·运维·前端·redis·缓存
时光匆匆岁月荏苒,转眼我们已不是当年2 小时前
【前端echarts】echarts双饼图与easyui列表联动
前端·echarts·easyui