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) // 加载至当前地图
相关推荐
天天扭码15 分钟前
从数组到对象:JavaScript 遍历语法全解析(ES5 到 ES6 + 超详细指南)
前端·javascript·面试
拉不动的猪16 分钟前
前端开发中常见的数据结构优化问题
前端·javascript·面试
街尾杂货店&17 分钟前
css word
前端·css
Мартин.20 分钟前
[Meachines] [Hard] CrimeStoppers LFI+ZIP-Shell+Firefox-Dec+DLINK+rootme-0.5
前端·firefox
冰镇生鲜20 分钟前
快速静态界面 MDC规则约束 示范
前端
技术与健康33 分钟前
【解读】Chrome 浏览器实验性功能全景
前端·chrome
Bald Monkey41 分钟前
【Element Plus】解决移动设备使用 el-menu 和 el-sub-menu 时,子菜单需要点击两次才会隐藏的问题
前端·elementui·vue·element plus
m0_709214341 小时前
利用Arcgis自己绘制shp文件
arcgis
小小小小宇1 小时前
PC和WebView白屏检测
前端
天天扭码1 小时前
ES6 Symbol 超详细教程:为什么它是避免对象属性冲突的终极方案?
前端·javascript·面试