-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
66 lines (61 loc) · 2.07 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/MapImageLayer"
], function (Map, MapView, MapImageLayer) {
Vue.component('map-component', {
template: `<div id="wrapper">
<div id="map"></div>
<div class="slider">
<output class="flex-item" for="sliderWithValue">SLR: {{ SLRVal }} ft</output>
<input v-model="SLRVal" step="1" min="0" max="10" value="0" type="range">
</div>
</div>`,
data: function () {
return {
map: Object,
SLRVal: 0,
seaLevelObject: {
lastVis: 0,
layers: []
},
urls: ["https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_0ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_1ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_2ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_3ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_4ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_5ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_6ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_7ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_8ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_9ft/MapServer", "https://coast.noaa.gov/arcgis/rest/services/dc_slr/slr_10ft/MapServer"]
}
},
watch: {
SLRVal: function (newVal) {
this.seaLevelObject.layers[newVal].visible = true;
this.seaLevelObject.layers[this.seaLevelObject.lastVis].visible = false;
this.seaLevelObject.lastVis = newVal;
}
},
mounted() {
var map = new Map({
basemap: "dark-gray-vector"
});
this.map = map;
var view = new MapView({
map: map,
container: 'map',
center: [-122.438556, 48.424270],
zoom: 11
});
this.urls.forEach(url => {
this.initMaplayer(url)
});
},
methods: {
initMaplayer(url) {
let newLayer = new MapImageLayer({
url: url,
visible: true
});
this.seaLevelObject.layers.push(newLayer)
this.map.add(newLayer);
}
}
});
var app = new Vue({
el: '#app'
});
});