-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
185 lines (158 loc) · 6.08 KB
/
index.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<meta charset="utf-8">
<title>Riot and esri-loader</title>
<style>
body {
margin: 8px 20px 60px 20px;
font-family: sans-serif;
display: flex;
flex-direction: column;
align-items: center;
}
esri-map-view {
/* this is the custom html tag/component, not a css class */
height: 200px;
width: 75%;
outline: 2px solid #ff0044;
margin: 5px 0;
}
.header {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.header span {
margin: 0 7px;
}
.header a:last-child {
font-family: monospace;
font-size: 1.25em;
}
a {
color: #ff0044;
}
code {
background-color: #e0e0e0;
font-size: 1.2em;
}
</style>
</head>
<body>
<h1 class="header">
<span>
made with
</span>
<a href="http://riotjs.com/">
<img src="./img/riot120x.png" alt="RiotJS logo" />
</a>
<span>
and
</span>
<a href="https://github.com/Esri/esri-loader/">esri-loader</a>
</h1>
<p>
This is an example
<a href="http://riotjs.com/">Riot</a> application that shows how to use
<a href="https://github.com/Esri/esri-loader">esri-loader</a> to create a custom
<code><esri-map-view></code> component.
</p>
<p>
There's a custom component below for each named basemap option in the ArcGIS API for JavaScript.
</p>
<ul>
<li>
<code><esri-map-view zoom="4" basemap="oceans"></esri-map-view></code>
</li>
<li>
<code><esri-map-view rotation="180" basemap="streets-vector"></esri-map-view></code>
</li>
<li>
And so many more. Take a look at
<a href="https://github.com/jwasilgeo/esri-riot-example">the source code</a>.
</li>
</ul>
<!-- show an <esri-map-view> for every named basemap in the ArcGIS API -->
<!-- see JS below for an example of passing in options via JS in addition to HTML attributes -->
<esri-map-view zoom="4" rotation="10" center="-18,65" basemap="streets"></esri-map-view>
<esri-map-view zoom="4" rotation="20" center="-18,65" basemap="satellite"></esri-map-view>
<esri-map-view zoom="4" rotation="30" center="-18,65" basemap="hybrid"></esri-map-view>
<esri-map-view zoom="4" rotation="40" center="-18,65" basemap="terrain"></esri-map-view>
<esri-map-view zoom="4" rotation="50" center="-18,65" basemap="topo"></esri-map-view>
<esri-map-view zoom="4" rotation="60" center="-18,65" basemap="gray"></esri-map-view>
<esri-map-view zoom="4" rotation="70" center="-18,65" basemap="dark-gray"></esri-map-view>
<esri-map-view zoom="4" rotation="80" center="-18,65" basemap="oceans"></esri-map-view>
<esri-map-view zoom="4" rotation="90" center="-18,65" basemap="national-geographic"></esri-map-view>
<esri-map-view zoom="4" rotation="100" center="-18,65" basemap="osm"></esri-map-view>
<esri-map-view zoom="3" rotation="110" center="-18,65" basemap="dark-gray-vector"></esri-map-view>
<esri-map-view zoom="3" rotation="120" center="-18,65" basemap="gray-vector"></esri-map-view>
<esri-map-view zoom="3" rotation="130" center="-18,65" basemap="streets-vector"></esri-map-view>
<esri-map-view zoom="4" rotation="140" center="-18,65" basemap="topo-vector"></esri-map-view>
<esri-map-view zoom="3" rotation="150" center="-18,65" basemap="streets-night-vector"></esri-map-view>
<esri-map-view zoom="4" rotation="160" center="-18,65" basemap="streets-relief-vector"></esri-map-view>
<esri-map-view zoom="3" rotation="170" center="-18,65" basemap="streets-navigation-vector"></esri-map-view>
<!-- load js dependency: riot.js and its compiler -->
<script src="https://unpkg.com/[email protected]/riot+compiler.min.js"></script>
<!-- load js dependency: esri-loader -->
<script src="https://unpkg.com/[email protected]"></script>
<!-- define an inlined riot tag (aka: component) that encapsulates an instance of an ArcGIS API v4 MapView -->
<script type="riot/tag">
<esri-map-view>
<!-- tag layout -->
<div ref="mapViewNode"></div>
<!-- tag style -->
<style>
.esri-view {
width: 100%;
height: 100%;
}
</style>
<!-- tag logic -->
// esri-loader is super smart and will not reload duplicate JS or CCS dependencies from the ArcGIS API
// use esri-loader to load the CSS required by the ArcGIS API
esriLoader.loadCss('https://js.arcgis.com/4.9/esri/css/view.css');
this.on('mount', function() {
// we need access to the tag's DOM element in the JS logic to construct a MapView instance
// see "ref" attribute in "tag-layout" above
// the corresponding refs JS object is only populated after the "mount" event
var mapViewNode = this.refs.mapViewNode;
// this.opts is an object of options properties set in either
// HTML above or riot application main JS entry point below
var basemap = this.opts.basemap || 'streets';
var zoom = this.opts.zoom || 1;
var center = this.opts.center ? this.opts.center.split(',') : [0, 0];
var rotation = this.opts.rotation || 0;
// use esri-loader to load the ArcGIS API modules required to construct a MapView instance
var esriLoaderOptions = {
url: 'https://js.arcgis.com/4.9/'
};
esriLoader.loadModules([
'esri/Map',
'esri/views/MapView',
], esriLoaderOptions)
.then(function([Map, MapView]) {
new MapView({
container: mapViewNode,
map: new Map({
basemap: basemap
}),
zoom: zoom,
center: center,
rotation: rotation,
ui: {
components: ['attribution', 'zoom', 'compass']
}
});
});
});
</esri-map-view>
</script>
<script>
// riot application main entry point:
// mount all custom "<esri-map-view>" riot tags on the page
riot.mount('esri-map-view');
</script>
</body>
</html>