-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (131 loc) · 3.74 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
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>tronGIS</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.4/esri/css/main.css">
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script src="https://js.arcgis.com/4.4/"></script>
</head>
<body>
<div id="viewDiv"> <button id="bMAPRM" type="button" class="my_button" onclick="rmBMAP();">Remove the basemap</button> </div>
</body>
</html>
<script>
var webmap;
require([
"esri/widgets/Locate",
"esri/widgets/ScaleBar",
"esri/widgets/LayerList",
"esri/widgets/Search",
"esri/widgets/Expand",
"esri/views/MapView",
"esri/WebMap",
"dojo/domReady!"
], function(Locate, ScaleBar, LayerList, Search, Expand, MapView, WebMap) {
/************************************************************
* Creates a new WebMap instance. A WebMap must reference
* a PortalItem ID that represents a WebMap saved to
* arcgis.com or an on-premise portal.
*
* To load a WebMap from an on-premise portal, set the portal
* url with esriConfig.portalUrl.
************************************************************/
webmap = new WebMap({
portalItem: {
// autocasts as new PortalItem()
id: "6b37524975cf45b497809d373868cdd1"
}
});
/************************************************************
* Set the WebMap instance to the map property in a MapView.
************************************************************/
var view = new MapView({
map: webmap,
container: "viewDiv"
});
/************************************************************
* Tracking
************************************************************/
var locateWidget = new Locate({
view: view
});
/************************************************************
* scaleBar
************************************************************/
var scaleBar = new ScaleBar({
view: view,
unit: "metric",
style: "ruler" // The scale bar displays both metric and non-metric units.
});
/************************************************************
* Layer List
************************************************************/
var layerList = new LayerList({
container: document.createElement("div"),
view: view
});
layerListExpand = new Expand({
expandIconClass: "esri-icon-layer-list",
view: view,
content: layerList.domNode
});
/************************************************************
* searchWidget
************************************************************/
var searchWidget = new Search({
view: view
});
/************************************************************
* UI Add event
************************************************************/
view.ui.add([
{
component: locateWidget,
position: "top-left",
index: 1
},
{
component: scaleBar,
position: "bottom-left",
index: 3
},
{
component: layerListExpand,
position: "bottom-right",
index: 0
},
{
component: searchWidget,
position: "top-right",
index: 0
},{
component: bMAPRM,
position: "bottom-left",
index: 1
}
]);
/************************************************************
* If NO interaction after 30s, Hide GUI
************************************************************/
/************************************************************
* If screen touch && gui doesn't exist, make gui
************************************************************/
});
function rmBMAP(){
webmap.basemap.baseLayers.forEach(function(item, i){
if(item.visible === true) {item.visible = false;} else {item.visible = true;}
});
}
</script>