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) // 加载至当前地图
相关推荐
豆苗学前端7 分钟前
【前端内功】同为数据驱动,为什么只有 React 的"心智负担"这么重?(附实战优化指南)
前端·vue.js·面试
铁皮饭盒11 分钟前
震惊, Bun突发新版, 重写核心, 换掉了底层Zig
前端·javascript·后端
IT_陈寒21 分钟前
深入理解Java:核心原理与最佳实践
前端·人工智能·后端
恋猫de小郭22 分钟前
Android Studio 放着没怎么用,怎么也会越来越卡?
android·前端·flutter
北暮城南25 分钟前
VS Code 与 IDEA 集成 Claude Code 实战指南——基于智谱 AI 大模型的 AI 辅助编码环境搭建
vscode·idea·claude·intellij idea·claude code·claude code cli
fanzhonghong25 分钟前
javaWeb开发之前端实战(Vue工程化+ElementPlus)
前端·javascript·vue.js·后端·spring
openKaka_27 分钟前
completeWork:真实 DOM 是在哪里被创建的
前端·javascript·react.js
希冀12331 分钟前
【CSS学习第六篇】
前端
Python大数据分析@32 分钟前
说说Markdown为什么不会被HTML取代
前端·html
史迪仔011236 分钟前
[QML] Qt5/6图像色彩空间处理
开发语言·前端·c++·qt