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) // 加载至当前地图
相关推荐
计算机魔术师11 分钟前
同样是AI辅助建造,为什么有的游戏三个月就烂尾了?
前端
用户9210802628622 分钟前
0. 做 Agent 产品,前端 AI 组件框架怎么选?
前端
拾年2751 小时前
React Hooks 进阶篇:useMemo / useCallback / useReducer / useImperativeHandle,用「算账 +
前端·javascript·react.js
Jackson__1 小时前
面试官:如何在老项目中使用新框架,并实现通信?
前端·javascript·面试
拾年2751 小时前
React Hooks 保姆级教程:把组件想象成失忆的打工人,4 个 Hook 带你原地起飞
前端·javascript·react.js
mmsx2 小时前
一个 Bug 修了 12 轮,根因只有一句话:AI 编程时代,日志才是唯一的真相
前端
默_笙2 小时前
😝 5 亿次循环卡死页面?我用 Web Worker 把它扔进后台线程,页面丝滑如初
前端·javascript
CAD老兵2 小时前
一行代码集成 DWG/DXF 图纸查看:测量批注,数据不出站
前端·javascript·github
小林ixn2 小时前
单例模式:从弹窗管理到全局状态,一个模式搞定
前端·javascript·设计模式
AI编程实验室2 小时前
Node.js Agent Handoff 仓库扫描 MVP:忽略规则、include 通配与稳定输出实现
前端·ai编程