|
@@ -50,7 +50,7 @@ |
50 |
50 |
|
title: place.name, |
51 |
51 |
|
position: pos |
52 |
52 |
|
})); |
53 |
|
- |
getMarkersBySearch(place, pos.lat, pos.lng, markers, window.tipologies, infowindow, map, iconSmart, contents); |
|
53 |
+ |
getMarkersBySearch(place, pos.lat, pos.lng, markers, window.tipologies, infowindow, map, iconSmart, contents, null); |
54 |
54 |
|
} else { |
55 |
55 |
|
alert("Posizione non trovata"); |
56 |
56 |
|
} |
|
@@ -84,7 +84,7 @@ |
84 |
84 |
|
}); |
85 |
85 |
|
} |
86 |
86 |
|
|
87 |
|
- |
function getMarkersBySearch(place, lat, lng, markers, tipologies, infowindow, map, iconSmart, contents){ |
|
87 |
+ |
function getMarkersBySearch(place, lat, lng, markers, tipologies, infowindow, map, iconSmart, contents, bounds){ |
88 |
88 |
|
function success(response){ |
89 |
89 |
|
if (response){ |
90 |
90 |
|
// Create the tipologies menu and link it to the UI element. |
|
@@ -150,6 +150,11 @@ |
150 |
150 |
|
'</div>'+ |
151 |
151 |
|
'</div>'; |
152 |
152 |
|
contents.push(content); |
|
153 |
+ |
if(bounds != null){ |
|
154 |
+ |
bounds.extend(new google.maps.LatLng(lat, lng)); |
|
155 |
+ |
bounds.extend(new google.maps.LatLng(parseFloat(response.locals[i].lat), parseFloat(response.locals[i].lon))); |
|
156 |
+ |
map.fitBounds(bounds); |
|
157 |
+ |
} |
153 |
158 |
|
google.maps.event.addListener(marker, 'click', (function(marker, i) { |
154 |
159 |
|
return function() { |
155 |
160 |
|
infowindow.setContent(contents[i]); |
|
@@ -158,6 +163,8 @@ |
158 |
163 |
|
} |
159 |
164 |
|
})(marker, i)); |
160 |
165 |
|
} |
|
166 |
+ |
|
|
167 |
+ |
|
161 |
168 |
|
} |
162 |
169 |
|
} |
163 |
170 |
|
|
|
@@ -296,9 +303,7 @@ |
296 |
303 |
|
}); |
297 |
304 |
|
markers = []; |
298 |
305 |
|
|
299 |
|
- |
// For each place, get the icon, name and location. |
300 |
306 |
|
var bounds = new google.maps.LatLngBounds(); |
301 |
|
- |
|
302 |
307 |
|
|
303 |
308 |
|
places.forEach(function(place) { |
304 |
309 |
|
var icon = { |
|
@@ -319,7 +324,7 @@ |
319 |
324 |
|
|
320 |
325 |
|
//var i; |
321 |
326 |
|
|
322 |
|
- |
getMarkersBySearch(place, lat, lng, markers, tipologies, infowindow, map, iconSmart, contents); |
|
327 |
+ |
getMarkersBySearch(place, lat, lng, markers, tipologies, infowindow, map, iconSmart, contents, bounds); |
323 |
328 |
|
|
324 |
329 |
|
|
325 |
330 |
|
if (place.geometry.viewport) { |
|
@@ -329,7 +334,7 @@ |
329 |
334 |
|
bounds.extend(place.geometry.location); |
330 |
335 |
|
} |
331 |
336 |
|
}); |
332 |
|
- |
map.fitBounds(bounds); |
|
337 |
+ |
//map.fitBounds(bounds); |
333 |
338 |
|
}); |
334 |
339 |
|
// [END region_getplaces] |
335 |
340 |
|
} |