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) // 加载至当前地图
相关推荐
凌冰_几秒前
Ajax 入门
前端·javascript·ajax
京东零售技术15 分钟前
京东小程序JS API仓颉改造实践
前端
老A技术联盟25 分钟前
从小白入门,基于Cursor开发一个前端小程序之Cursor 编程实践与案例分析
前端·小程序
风铃喵游28 分钟前
构建引擎: 打造小程序编译器
前端·小程序·架构
sunbyte33 分钟前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | ThemeClock(主题时钟)
前端·javascript·css·vue.js·前端框架·tailwindcss
小飞悟41 分钟前
🎯 什么是模块化?CommonJS 和 ES6 Modules 到底有什么区别?小白也能看懂
前端·javascript·设计
浏览器API调用工程师_Taylor42 分钟前
AOP魔法:一招实现登录弹窗的全局拦截与动态处理
前端·javascript·vue.js
FogLetter43 分钟前
初识图片懒加载:让网页像"懒人"一样聪明加载
前端·javascript
微客鸟窝44 分钟前
一文搞懂NVM管理Node.js:从安装到实战全攻略
前端
归于尽1 小时前
Cookie、Session、JWT 的前世今生
前端