本文学习的是如何在一个 2D map 上展示图层,本文使用的是 ArcGIS Online 的图层。
这次学习用到的图层是 Trailheads,Trails,Parks and Open Spaces。
先把 FeatureLayer 模块加到 require 里面,分别通过url创建点图层(Trailheads),线图层(Trails),面图层(Parks and Open Spaces);并用 map.add() 方法将图层一一叠加到底图上。
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer"
], function(Map, MapView, FeatureLayer) {
// Trailheads feature layer (points)
var trailheadsLayer = new FeatureLayer({
url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0"
});
map.add(trailheadsLayer);
// Trails feature layer (lines)
var trailsLayer = new FeatureLayer({
url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0"
});
map.add(trailsLayer, 0);