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) // 加载至当前地图
相关推荐
椰羊~王小美5 分钟前
前后端 格式化货币的方法
java·前端
苯酸氨酰糖化物5 分钟前
HTML+CSS学信网学籍学历查询页面-支持任意修改内容信息
前端·css3·html5·娱乐
幻云20106 分钟前
Next.js 之道:从入门到精通
前端·javascript·vue.js·人工智能·python
2501_9445215911 分钟前
Flutter for OpenHarmony 微动漫App实战:标签筛选功能实现
android·开发语言·前端·javascript·flutter
EndingCoder14 分钟前
构建工具集成:Webpack 和 TypeScript
前端·webpack·typescript
卡西里弗斯奥17 分钟前
【Tomcat】部署Web服务器之Tomcat
服务器·前端·tomcat
Sheldon一蓑烟雨任平生34 分钟前
Sass 星空(Sass + keyframes 实现星空动画)
前端·css·vue3·sass·keyframes
⑩-41 分钟前
VUE3学习
前端·javascript·vue.js
Mr Xu_1 小时前
Vue 3 中使用 mitt 实现组件间通信的实践与解析
前端·javascript·vue.js
呃m1 小时前
更好地使用Google Chrome
前端·chrome