-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.html
More file actions
184 lines (144 loc) · 4.33 KB
/
Copy pathAPI.html
File metadata and controls
184 lines (144 loc) · 4.33 KB
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
<!DOCTYPE html>
<html lang="fa" >
<head>
<meta charset="UTF-8" />
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Routing Result With NESHAN</title>
<link rel="stylesheet" href="https://static.neshan.org/sdk/mapboxgl/v1.13.2/neshan-sdk/v1.1.1/index.css" />
<script src="https://static.neshan.org/sdk/mapboxgl/v1.13.2/neshan-sdk/v1.1.1/index.js"></script>
<link rel="stylesheet" href="https://static.neshan.org/sdk/mapboxgl/v1.13.2/neshan-sdk/v1.1.1/index.css" />
<script src="https://static.neshan.org/sdk/mapboxgl/v1.13.2/neshan-sdk/v1.1.1/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-polyline/1.2.1/polyline.js"></script>
<style>
body {
height: 100vh;
width: 100vw;
margin: 0;
}
#map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
window.onload = function() {
let Response = JSON.parse(localStorage.getItem("Result_JSON"));
let A_1 = localStorage.getItem("A_1")
let A_2 = localStorage.getItem("A_2")
let B_1 = localStorage.getItem("B_1")
let B_2 = localStorage.getItem("B_2")
let C_1 = localStorage.getItem("C_1")
let C_2 = localStorage.getItem("C_2")
let D_1 = localStorage.getItem("D_1")
let D_2 = localStorage.getItem("D_2")
console.log("recive" , Response);
const neshanMap = new nmp_mapboxgl.Map({
mapType: nmp_mapboxgl.Map.mapTypes.neshanVector,
container: "map",
zoom: 12,
pitch: 0,
center: [A_1, A_2],
minZoom: 2,
maxZoom: 21,
trackResize: true,
mapKey: "web.9e03ae0de3ab4eb5bc619c13117e2e2c",
poi: true,
traffic: false,
mapTypeControllerOptions: {
show: true,
},
});
var routes = [];
var points = [];
for (let k = 0; k < Response.routes.length; k++) {
for (let j = 0; j < Response.routes[k].legs.length; j++) {
for (let i = 0; i < Response.routes[k].legs[j].steps.length; i++) {
var step = Response.routes[k].legs[j].steps[i]["polyline"];
var point = Response.routes[k].legs[j].steps[i]["start_location"];
var route = polyline.decode(step, 5);
route.map(item => { item.reverse() })
routes.push(route);
points.push(point);
}
}
}
var routeObj = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'MultiLineString',
coordinates: routes
}
}
]
};
var pointsObj = {
type: 'FeatureCollection',
features: [
{
type:"Feature",
geometry:
{
"type": "MultiPoint",
"coordinates": points
}
}
]
};
neshanMap.on('load', function () {
neshanMap.addSource('route', {
type: 'geojson',
data: routeObj
});
neshanMap.addSource('points1', {
type: 'geojson',
data: pointsObj
});
neshanMap.addLayer({
id: 'route-line',
type: 'line',
source: 'route',
layout: {
'line-join': 'round',
'line-cap': 'round'
},
paint: {
'line-color': '#250ECD',
'line-width': 9
}
});
neshanMap.addLayer({
id: 'points1',
type: 'circle',
source: 'points1',
paint: {
"circle-color" : "#9fbef9",
"circle-stroke-color":"#FFFFFF",
"circle-stroke-width": 2,
"circle-radius" : 5
}
});
});
var marker_with_popup1 = new nmp_mapboxgl.Marker({ color: "#d90b0b" })
.setLngLat([A_1, A_2])
.addTo(neshanMap);
var marker_with_popup2 = new nmp_mapboxgl.Marker({ color: "#0b34d9" })
.setLngLat([B_1, B_2])
.addTo(neshanMap);
var marker_with_popup3 = new nmp_mapboxgl.Marker({ color: "#0bd91f" })
.setLngLat([C_1, C_2])
.addTo(neshanMap);
var marker_with_popup4 = new nmp_mapboxgl.Marker({ color: "#cbd90b" })
.setLngLat([D_1, D_2])
.addTo(neshanMap);
}
</script>
</body>
</html>