-
Notifications
You must be signed in to change notification settings - Fork 3
/
map.php
192 lines (179 loc) · 6.74 KB
/
map.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
188
189
190
191
192
<?php
require_once 'data/protected/config.php';
?>
<!doctype html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<style type="text/css">
.container {
background-size: cover;
background: rgba(255, 255, 255, 0.7);
margin-left: auto;
margin-right: auto;
border-radius: 10px !important;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3), 0 6px 20px 0 rgba(0, 0, 0, 0.3);
}
.container-fluid {
height: 100%;
padding: 0 !important;
}
.col-nearest-places img {
width: 80px;
margin-right: 10px;
margin-bottom: 7px;
}
#links img {
height: 30px;
width: 30px;
opacity: 0.8;
margin: 5px;
}
@media (min-width: 768px) {
#links {
position: absolute;
bottom: 10px;
}
}
</style>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div id="db-mode" style="display: none"><?php echo $_GET['mode'] ?></div>
<div class="container-fluid">
<div id="map"></div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
<script>
const base_url = "https://www.niceplaces.it/";
//const base_url = "http://localhost/niceplaces/";
let map;
let myposition;
function initMap() {
luoghi = new google.maps.Map(document.getElementById('map'), {
center: {lat: 42, lng: 12},
zoom: 5.8
});
}
function loadMap() {
luoghi = new google.maps.Map(document.getElementById('map'), {
center: myposition,
zoom: 8,
styles: [
{
"featureType": "administrative",
"elementType": "geometry",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"stylers": [
{
"visibility": "off"
}
]
}
]
});
let marker = new google.maps.Marker({
position: myposition,
map: luoghi,
title: 'La mia posizione'
});
}
let mode = document.getElementById('db-mode').textContent
let url = base_url + "data/query.php?version=v3&mode=" + mode + "&p1=getnearestplaces&p2=" + 43 + "&p3=" + 11 + "&p4=10000";
$.ajax({
url: url,
type: "GET",
contentType: "application/json",
success: function (result) {
let markers = [];
for (let i = 0; i < result.length; i++) {
let icon = {
url: base_url + "data/image.php?mode=" + mode + "&file=" + result[i].image + "&w=200&h=200&shape=circle",
scaledSize: new google.maps.Size(50, 50), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(25, 25) // anchor
};
let marker = new google.maps.Marker({
position: {lat: parseFloat(result[i].latitude), lng: parseFloat(result[i].longitude)},
map: luoghi,
title: result[i].name,
icon: icon
});
marker.addListener('click', function () {
window.open(base_url + result[i].id_string_area + "/" + result[i].id_string_place);
});
markers.push(marker);
let image = '<div style="display: inline" class="col-md-12"> ' +
'<div style="display: inline-block; width: 100px; border-radius: 50px; text-align: center" class="row">' +
'<div style="display: inline; position: relative; ' +
'background-image: url(" ' + base_url + 'data/image.php?mode=' + mode + '&name=' + result[i].image + '&w=100&h=100")"' +
'class="col-sm-12 col-md-6"></div>' +
'<div style="display: inline; position: absolute; left: 0; top: 70px" class="col-sm-12 col-md-6"> ' +
result[i].name + "<br/>" + result[i].distance_km +
'</div></div></div>';
$(".row-places-list").append(image);
}
let markerCluster = new MarkerClusterer(luoghi, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
markerCluster.setGridSize(30);
},
error: function (error) {
console.log(error);
}
});
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo $gmapsApiKey ?>&callback=initMap"></script>
</body>
</html>