-
Notifications
You must be signed in to change notification settings - Fork 1
/
Itinéraire.html
327 lines (269 loc) · 11.2 KB
/
Itinéraire.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html lang="en"><!-- Basic -->
<head>
<base target="_top">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Mobile Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Site Metas -->
<title>Géoportail Des Parcs Nationaux</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="">
<!-- Site Icons -->
<link rel="shortcut icon" href="Image/georeserve.png" >
<link rel="apple-touch-icon" href="Image/">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="Css/bootstrap.min.css">
<!-- Site CSS -->
<link rel="stylesheet" href="Css/style.css">
<!-- Pickadate CSS -->
<link rel="stylesheet" href="Css/classic.css">
<link rel="stylesheet" href="Css/classic.date.css">
<link rel="stylesheet" href="Css/classic.time.css">
<!-- Responsive CSS -->
<link rel="stylesheet" href="Css/responsive.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="Css/custom.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<!-- Load jQuery and PapaParse to read data from a CSV file -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.3.0/papaparse.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.3.0/papaparse.min.js"></script>
<title>Layers Control Tutorial - Leaflet</title>
<link rel="shortcut icon" href="Image/georeserve.png" type="image/x-icon">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="Css/leaflet.css"/>
<script src="Js/leaflet.js"></script>
<link rel="stylesheet" href="Css/leaflet.zoomhome.css"/>
<script src="Js/leaflet.zoomhome.min.js"></script>
<!-- Load Leaflet from CDN -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js" crossorigin=""></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://unpkg.com/esri-leaflet@^3.0.8/dist/esri-leaflet.js"></script>
<script src="https://unpkg.com/esri-leaflet-vector@4.0.0/dist/esri-leaflet-vector.js"></script>
<!-- Load ArcGIS REST JS from CDN -->
<script src="https://unpkg.com/@esri/arcgis-rest-request@4.0.0/dist/bundled/request.umd.js"></script>
<script src="https://unpkg.com/@esri/arcgis-rest-routing@4.0.0/dist/bundled/routing.umd.js"></script>
<!-- Load Esri Leaflet Geocoder from CDN -->
<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@^3.1.3/dist/esri-leaflet-geocoder.css">
<script src="https://unpkg.com/esri-leaflet-geocoder@^3.1.3/dist/esri-leaflet-geocoder.js"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Start header -->
<header class="top-navbar">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="index.html">
<img src="images/logogeotourisme.png" alt="" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars-rs-food" aria-controls="navbars-rs-food" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars-rs-food">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="index.html">Accueil</a></li>
<li class="nav-item"><a class="nav-link" href="about.html">Informations</a></li>
<li class="nav-item"><a class="nav-link" href="storymap\index1.html" target="_blank">Géoportail</a> </li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown-a" data-toggle="dropdown">Cartes thématiques</a>
<div class="dropdown-menu" aria-labelledby="dropdown-a">
<a class="dropdown-item" href="Carte des superficies.html">Carte des superficies</a>
<a class="dropdown-item" href="Carte NDVI.html">Carte NDVI</a>
<a class="dropdown-item" href="Visualisation 3D.html" target="_blank">Visualisation 3D</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown-a" data-toggle="dropdown">Recherche</a>
<div class="dropdown-menu" aria-labelledby="dropdown-a">
<a class="dropdown-item" href="Recherche.html">Attributaires</a>
<a class="dropdown-item" href="Recherche2.html">Spatiales</a>
<a class="dropdown-item" href="Itinéraire.html">Itinéraire</a>
</div>
</li>
<li class="nav-item"><a class="nav-link" href="contact.html">Contact</a></li>
</ul>
</div>
</div>
</nav>
</header>
<!-- End header -->
<!-- Start All Pages -->
<div class="all-page-title page-breadcrumb">
<div class="container text-center">
<div class="row">
<div class="col-lg-12">
<h1>Itinéraire</h1>
<br><br>
</div>
</div>
</div>
</div>
<!-- End All Pages -->
<div class="blog-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="heading-title text-center">
<br><br>
<p> </p>
<head>
<style>
#map {
height: 500px ;
width: 1000px;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #323232;
display: block;
margin-left: auto;
margin-right: auto;
padding: 100px;
right: 20px;
}
#directions {
position: absolute;
z-index: 1000;
width: 30%;
max-height: 50%;
left: 50px;
bottom: 20px;
overflow-y: auto; /* Show a scrollbar if needed */
background: rgb(255, 255, 255);
font-family: Arial, Helvetica, Verdana;
line-height: 2;
font-size: 10px;
padding: 50px;}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
const map = L.map("map", {
minZoom: 2
})
map.setView([29.638933, -9.665423], 5);
const apiKey = "AAPK22b2239330f348e6856b49ba92d3aa36l-qSfkzwWqJOSvuCHty6k4cDtOREFtSJoPiRlta-1uwftZL9sBYHbKzcDXjD4ZK5";
const basemapEnum ="ArcGIS:Streets";
L.esri.Vector.vectorBasemapLayer(basemapEnum, {
apiKey: apiKey
}).addTo(map);
var Maroc = L.esri
.featureLayer({
url: "https://services6.arcgis.com/f4ktY2fh4AlEsjcx/arcgis/rest/services/maroc/FeatureServer/0",
style: {
color: "#000000",
weight: 5
}});
Maroc.addTo(map);
var Parc = L.esri
.featureLayer({
url: "https://services6.arcgis.com/f4ktY2fh4AlEsjcx/arcgis/rest/services/parc/FeatureServer/0",
style: {
color: "#FFFFFF",
weight: 5
}});
Parc.addTo(map);
const searchControl = L.esri.Geocoding.geosearch({
position: "topright",
placeholder: "Entrez une adresse",
useMapBounds: false,
providers: [
L.esri.Geocoding.arcgisOnlineProvider({
apikey: apiKey,
nearby: {
lat: 29.638933,
lng: -9.665423
}
})
]
}).addTo(map);
const results = L.layerGroup().addTo(map);
searchControl.on("results", (data) => {
results.clearLayers();
for (let i = data.results.length - 1; i >= 0; i--) {
const marker = L.marker(data.results[i].latlng);
const lngLatString = `${Math.round(data.results[i].latlng.lng * 100000) / 100000}, ${
Math.round(data.results[i].latlng.lat * 100000) / 100000
}`;
marker.bindPopup(`<b>${lngLatString}</b><p>${data.results[i].properties.LongLabel}</p>`);
results.addLayer(marker);
marker.openPopup();
}
}
)
const directions = document.createElement("div");
directions.id = "directions";
directions.innerHTML = "Click on the map to create a start and end for the route.";
document.body.appendChild(directions);
const startLayerGroup = L.layerGroup().addTo(map);
const endLayerGroup = L.layerGroup().addTo(map);
const routeLines = L.layerGroup().addTo(map);
let currentStep = "start";
let startCoords, endCoords;
function updateRoute() {
// Create the arcgis-rest-js authentication object to use later.
const authentication = arcgisRest.ApiKeyManager.fromKey(apiKey);
// make the API request
arcgisRest
.solveRoute({
stops: [startCoords, endCoords],
endpoint: "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve",
authentication
})
.then((response) => {
routeLines.clearLayers();
L.geoJSON(response.routes.geoJson).addTo(routeLines);
const directionsHTML = response.directions[0].features.map((f) => f.attributes.text).join("<br/>");
directions.innerHTML = directionsHTML;
startCoords = null;
endCoords = null;
})
.catch((error) => {
console.error(error);
alert("There was a problem using the route service. See the console for details.");
});
}
map.on("click", (e) => {
const coordinates = [e.latlng.lng, e.latlng.lat];
if (currentStep === "start") {
startLayerGroup.clearLayers();
endLayerGroup.clearLayers();
routeLines.clearLayers();
L.marker(e.latlng).addTo(startLayerGroup);
startCoords = coordinates;
currentStep = "end";
} else {
L.marker(e.latlng).addTo(endLayerGroup);
endCoords = coordinates;
currentStep = "start";
}
if (startCoords && endCoords) {
updateRoute();
}
});
</script>
<a href="#" id="back-to-top" title="Back to top" style="display: none;">↑</a>
<!-- ALL JS FILES -->
<script src="Js/jquery-3.2.1.min.js"></script>
<script src="Js/popper.min.js"></script>
<script src="Js/bootstrap.min.js"></script>
<!-- ALL PLUGINS -->
<script src="Js/jquery.superslides.min.js"></script>
<script src="Js/images-loded.min.js"></script>
<script src="Js/isotope.min.js"></script>
<script src="Js/form-validator.min.js"></script>
<script src="Js/contact-form-script.js"></script>
<script src="Js/custom.js"></script>
</body>
</html>