forked from ynunokawa/L.esri.WebMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (78 loc) · 3.2 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
<html>
<head>
<meta charset=utf-8 />
<title>L.esri.WebMap Demo</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.css" />
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet-src.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.3/esri-leaflet.js"></script>
<!-- Load Leaflet Heat from CDN -->
<script src="https://rawgit.com/Leaflet/Leaflet.heat/gh-pages/dist/leaflet-heat.js"></script>
<!-- Load Heatmap Feature Layer from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri.heatmap-feature-layer/2.0.0-beta.1/esri-leaflet-heatmap-feature-layer.js"></script>
<!-- Load Esri Leaflet Vector Tile from CDN -->
<script src="//unpkg.com/[email protected]"></script>
<!-- Load Esri Leaflet Renderers from CDN -->
<script src="//cdn.jsdelivr.net/leaflet.esri.renderers/2.0.3/esri-leaflet-renderers.js"></script>
<!-- Load Vector Icon from GitHub -->
<script src="https://muxlab.github.io/Leaflet.VectorIcon/L.VectorIcon.js"></script>
<!-- Load Leaflet Omnivore from CDN -->
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.3.1/leaflet-omnivore.min.js'></script>
<!-- Load L.esri.WebMap -->
<script src="dist/esri-leaflet-webmap-debug.js"></script>
<style>
body { margin:0; padding:0; }
#map { position: absolute; top:0; bottom:0; right:0; left:0; }
.map-title-control {
background-color: #fff;
text-align: center;
text-decoration: none;
color: black;
padding: 10px;
border: 2px solid rgba(0,0,0,0.2);
border-radius: 4px;
font: bold 1em 'Lucida Console', 'Meiryo', Monaco, monospace;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var webmapId = '22c504d229f14c789c5b49ebff38b941'; // Default WebMap ID
var urlParams = location.search.substring(1).split('&');
for(var i=0; urlParams[i]; i++) {
var param = urlParams[i].split('=');
if(param[0] === 'webmap') {
webmapId = param[1]
}
}
var webmap = L.esri.webMap(webmapId, { map: L.map("map") });
webmap.on('metadataLoad', function() {
var MapTitleControl = L.Control.extend({
options: {
position: 'topright'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'map-title-control');
container.innerHTML = '<a target="_brank" href="http://www.arcgis.com/home/webmap/viewer.html?webmap=' + webmapId + '">' + webmap.title + '</a>'; // Add link to a webmap.
return container;
}
});
webmap._map.addControl(new MapTitleControl());
});
webmap.on('load', function() {
console.log('webmap loaded', webmap.layers);
var overlayMaps = {};
webmap.layers.map(function(l) {
console.log(l);
overlayMaps[l.title] = l.layer;
});
L.control.layers({}, overlayMaps, {
position: 'bottomright'
}).addTo(webmap._map);
});
</script>
</body>
</html>