This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-custom-lods.html
113 lines (99 loc) · 3.55 KB
/
example-custom-lods.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
<!DOCTYPE html>
<html>
<head>
<title>layer-selector Tests</title>
<!-- META TAGS -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- CSS -->
<link rel="stylesheet" href="../resources/LayerSelector.css">
<link rel="stylesheet" href="../node_modules/arcgis-js-api/css/main.css">
<style type="text/css">
body, html, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
<!-- JAVASCRIPT -->
<script type="text/javascript" src="dojoConfig.js"></script>
<script type="text/javascript" src="../node_modules/dojo/dojo.js"></script>
<script type="text/javascript">
var widgetUnderTest;
require([
'layer-selector',
'esri/config',
'esri/map',
'esri/views/MapView',
'esri/geometry/SpatialReference',
'esri/geometry/Extent',
'esri/geometry/Point',
'esri/layers/WebTileLayer',
'esri/layers/support/TileInfo',
'dojo/domReady!'
], function (Module, esriConfig, Map, MapView, SpatialReference, Extent, Point, WebTileLayer, TileInfo) {
esriConfig.request.corsEnabledServers.push(
'a.tile.stamen.com',
'b.tile.stamen.com',
'c.tile.stamen.com',
'd.tile.stamen.com'
);
var tilesize = 256;
var earthCircumference = 40075016.685568;
var halfEarthCircumference = halfEarthCircumference * 0.5;
var inchesPerMeter = 39.37;
var initialResolution = earthCircumference / tilesize;
var lods = [];
for (var zoom = 0; zoom <= 20; zoom++) {
var resolution = initialResolution / Math.pow(2, zoom);
var scale = resolution * 96 * inchesPerMeter;
lods.push({
level: zoom,
scale: scale,
resolution: resolution
});
}
var map = new Map();
var mapView = new MapView({
map: map,
container: 'map'
});
fiveNineteen = lods.slice(0, 20);
fiveSeventeen = lods.slice(0, 18);
widgetUnderTest = new Module({
mapView: mapView,
baseLayers: [
{
Factory: WebTileLayer,
urlTemplate: 'http://{subDomain}.tile.stamen.com/toner/{level}/{col}/{row}.png',
id: 'Imagery',
subDomains: ['a', 'b', 'c', 'd'],
selected: true,
tileInfo: new TileInfo({
dpi: 96,
rows: 256,
cols: 256,
origin: {
x: -20037508.342787,
y: 20037508.342787
},
spatialReference: {
wkid: 102100
},
lods: lods
})
}]
});
widgetUnderTest.startup();
});
</script>
</head>
<body>
<div id="map"></div>
<div class="node" id="node"></div>
<div class="node" id="node2"></div>
<div class="node" id="node3"></div>
<div class="node" id="node4"></div>
</body>
</html>