-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
187 lines (149 loc) · 6.51 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
186
187
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="https://js.arcgis.com/4.25/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.25/"></script>
<style>
body, html {
background-color: powderblue;
padding: 0px;
margin: 0px;
}
#viewDiv {
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
}
h1 {color: blue;}
p {color: red;}
</style>
<script >
require([
"esri/config",
"esri/Map",
"esri/views/MapView",
"esri/layers/GeoJSONLayer",
"esri/symbols/PictureMarkerSymbol",
"esri/widgets/ScaleBar" ],
(esriConfig, Map, MapView,GeoJSONLayer,PictureMarkerSymbol, ScaleBar ) => {
// Code to create the map and view will go here
esriConfig.apiKey = "AAPK5ccc46252aae40d5b0fdbe501d827298qL7FPPJOvUauW1BNVT5AYoqWx4eSIkNWomcqeBKRrhsFpT4mBzs8OacfGRwR8UIe";
var request = new XMLHttpRequest();
request.open("GET","./sensores.geojson", false);
request.send(null);
const mapGeoJson = JSON.parse(request.responseText);
const blob = new Blob([JSON.stringify(mapGeoJson)], {
type: 'application/json',
});
const url = URL.createObjectURL(blob);
//symbols
const coneSymbol = {
type: "picture-marker", // autocasts as new PictureMarkerSymbol()
url: "1.svg",
width: "20px",
height: "20px"
}
const diamondSymbol = {
type: "picture-marker", // autocasts as new PictureMarkerSymbol()
url: "2.svg",
width: "20px",
height: "20px"
}
const cubeSymbol = {
type: "picture-marker", // autocasts as new PictureMarkerSymbol()
url: "3.svg",
width: "20px",
height: "20px"
}
const globesSymbol = {
type: "picture-marker", // autocasts as new PictureMarkerSymbol()
url: "4.svg",
width: "20px",
height: "20px"
}
const simpleRenderer = {
type: "simple",
symbol: coneSymbol
,
};
const uniqueRenderer = {
type: "unique-value",
field:"sensor_type",
defaultSymbol: {type:"simple-fill"},
uniqueValueInfos: [{
value:"a",
symbol: coneSymbol
},{
value:"b",
symbol: diamondSymbol
},{
value:'c',
symbol: cubeSymbol
},{
value:'d',
symbol:globesSymbol
}]
}
uniqueRenderer.visualVariables = [{
type: "sizeInfo",
valueExpression: "$view.scale",
stops: [
// view scales larger than 1:1,155,581
// will have a symbol size of 7.5 pts
{ size: 6, value: 9244648 },
// view scales smaller than 1:591,657,527
// will have a symbol size of 1.5 pts
{ size: 32, value: 591657527 }
]
}]
/* {
type: "simple-marker",
color: "orange",
outline: {
color: "white",
}
} */
const layer = new GeoJSONLayer({
url,
renderer: uniqueRenderer
});
console.log({layer})
const map = new Map({
basemap: "arcgis-imagery",
layers: [layer]
});
const view = new MapView({
map: map,
center: [35.705376, 28.063534], // Longitude, latitude
zoom: 15, // Zoom level
container: "viewDiv", // Div element
});
let scaleBar = new ScaleBar({
view: view,
unit: 'metric'
});
view.ui.add(scaleBar, {
position: "bottom-left"
});
console.log(view.scale)
});
</script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="viewDiv"></div>
</body>
</html>