-
Notifications
You must be signed in to change notification settings - Fork 0
/
new 1.php
187 lines (146 loc) · 4.48 KB
/
new 1.php
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
<body>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=KEY&callback=myMap"></script>
<script type="text/javascript">
var myarray=<?php echo json_encode($videosetting); ?>;
document.write("<br>array <br>")
document.write(myarray)
document.write("<br>array[0] <br>")
document.write(myarray[0])
document.write("<br>array[1] <br>")
document.write(myarray[1])
var count= <?php echo $count; ?>;
document.write(count)
var markes=[];
for (var i=0; i<count ;i++) {
markes[i]= [
{
"title": 'Reduit',
"lat": myarray[i][2],
"lng": myarray[i][3],
"description": 'reduit'
}
,
{
"title": 'Bagatelle',
"lat": myarray[i][4],
"lng": myarray[i][5],
"description": 'bagatelle'
}
,
{
"title": 'Bagatelle',
"lat": myarray[i][8],
"lng": myarray[i][9],
"description": 'bagatelle'
}
,
{
"title": 'Reduit',
"lat": myarray[i][6],
"lng": myarray[i][7],
"description": 'reduit'
}
];
}
window.onload = function () {
var mapOptions = {
center: new google.maps.LatLng(markes[0][1].lat, markes[0][1].lng),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
var infoWindow = new google.maps.InfoWindow();
var latlngbounds = new google.maps.LatLngBounds();
//Creating Markers
var data=[];
var myLatlng=[];
var marker=[];
//var lat_lng = new Array();
var lat_lng = [];
for (var i=0;i<count; i++) {
for (j = 0; j < markes[i].length; j++) {
data[j] = markes[i][j];
myLatlng[j] = new google.maps.LatLng(data[j].lat, data[j].lng);
lat_lng.push(myLatlng[j]);
//lat_lng[j]=myLatlng[j];
marker[j] = new google.maps.Marker
(
{
position: myLatlng[j],
map: map,
title: data[j].title
}
);
latlngbounds.extend(marker[j].position);
(
function (marker, data)
{
google.maps.event.addListener
( marker, "click", function (e)
{
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
}
);
}
)(marker[j], data[j]);
}
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
}
//Initialize the Path Array
//Initialize the Direction Service
//Set the Path Stroke Color
var color=['#0EF022','#FF0000','#FFFF00','#00FF00','#00FFFF','#0000FF','#000000','FFFFFF'];
var src_des=[];
var j=0;
for (i=0;i<lat_lng.length;i++) {
src_des[j]=[lat_lng[i],lat_lng[i+1]];
j+=1;
i+=1;
}
for (var t = 0;t < src_des.length; t++)
{
//Intialize the Direction Service
var service = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var bounds = new google.maps.LatLngBounds();
if ((t + 1) < lat_lng.length)
{
var src = src_des[t][0];
var des = src_des[t][1];
service.route(
{
origin: src,
destination: des,
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
function(result, status)
{
if (status == google.maps.DirectionsStatus.OK)
{
// new path for the next result
var path = new google.maps.MVCArray();
//Set the Path Stroke Color
// new polyline for the next result
var poly = new google.maps.Polyline(
{
map: map,
strokeColor: color[t]
});
poly.setPath(path);
for (var k = 0, len = result.routes[0].overview_path.length; k < len; k++)
{
path.push(result.routes[0].overview_path[k]);
bounds.extend(result.routes[0].overview_path[k]);
map.fitBounds(bounds);
}
} else alert("Directions Service failed:" + status);
});
}
}
}// window.onload = function ()
</script>
<div id="dvMap" style="width: 100%; height: 800px">
</div>