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) // 加载至当前地图
相关推荐
用户新14 分钟前
V8引擎 精品漫游指南--Ignition篇(中) AST详解 字节码的生成
前端·javascript
岱宗夫up22 分钟前
【前端基础】HTML + CSS + JavaScript 基础(三)
开发语言·前端·javascript·css·html
凌云拓界1 小时前
TypeWell全攻略:AI健康教练+实时热力图开发实战 引言
前端·人工智能·后端·python·交互·pyqt·数据可视化
明月_清风1 小时前
三件套快速上手 + 第一个可安装的 PWA(HTTPS + Manifest + 基础 Service Worker)
前端·pwa
菜鸟小芯1 小时前
【GLM-5 陪练式前端新手入门】第三篇:网页导航栏 —— 搭建个人主页的 “指路牌”
前端
明月_清风1 小时前
PWA 到底是什么?它在 2026 年解决了哪些真实痛点?
前端·pwa
水木姚姚1 小时前
string类(C++)
开发语言·c++·windows·vscode·开发工具
甲枫叶1 小时前
【claude产品经理系列13】核心功能实现——需求的增删改查全流程
java·前端·人工智能·python·产品经理·ai编程
蓝帆傲亦2 小时前
Vue.js 大数据处理全景解析:从加载策略到渲染优化的完全手册
前端·vue.js·flutter
不会敲代码12 小时前
React组件通信实战:从Todo应用彻底搞懂父子、子父、兄弟通信
前端·react.js