This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h2>Add/Remove Layers</h2> | ||
<!-- add map to page --> | ||
<esri-map id="map" map-options="{ | ||
center: [-122.676207, 45.523452], | ||
zoom: 12, | ||
basemap: 'topo' | ||
}"> | ||
<!-- watch list of selected layers and add/remove each to/from the map --> | ||
<esri-feature-layer ng-repeat="url in selectedLayers" url="{{url}}"></esri-feature-layer> | ||
</esri-map> | ||
<p>Click the checkbox next to each layer to add or remove it to/from the map.</p> | ||
<div ng-repeat="layer in layers"> | ||
<input type="checkbox" ng-model="selected" ng-change="toggleLayer(layer.url)" /> {{layer.name}} <br /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
angular.module('esri-map-docs') | ||
.controller('AddRemoveLayersCtrl', function($scope) { | ||
// list of layers that can be added to the map | ||
$scope.layers = [ | ||
{ | ||
name: 'Heritage Trees', | ||
url: 'http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Heritage_Trees_Portland/FeatureServer/0' | ||
}, | ||
{ | ||
name: 'Parks', | ||
url: 'http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Portland_Parks/FeatureServer/0' | ||
} | ||
]; | ||
|
||
// list of layers currently added to the map | ||
$scope.selectedLayers = []; | ||
|
||
// add/remove a layer to/from the map by URL | ||
$scope.toggleLayer = function (url) { | ||
console.log('Toggling ' + url); | ||
var index = $scope.selectedLayers.indexOf(url); | ||
if (index >= 0) { | ||
$scope.selectedLayers.splice(index, 1); | ||
} else { | ||
$scope.selectedLayers.push(url); | ||
} | ||
console.log('Selected layers: ' + $scope.selectedLayers); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters