|
@@ -66,24 +66,6 @@ |
66 |
66 |
|
} |
67 |
67 |
|
} |
68 |
68 |
|
|
69 |
|
- |
function getPlaceInfo(lat, lng){ |
70 |
|
- |
var geocoder = new google.maps.Geocoder(); |
71 |
|
- |
var latlng = new google.maps.LatLng(lat, lng); |
72 |
|
- |
geocoder.geocode({'latLng': latlng}, function(results, status) { |
73 |
|
- |
if (status == google.maps.GeocoderStatus.OK) { |
74 |
|
- |
//console.log(results) |
75 |
|
- |
if (results[1]) { |
76 |
|
- |
//formatted address |
77 |
|
- |
return results[0].formatted_address; |
78 |
|
- |
} else { |
79 |
|
- |
return false; |
80 |
|
- |
} |
81 |
|
- |
} else { |
82 |
|
- |
return false; |
83 |
|
- |
} |
84 |
|
- |
}); |
85 |
|
- |
} |
86 |
|
- |
|
87 |
69 |
|
function getMarkersBySearch(place, lat, lng, markers, tipologies, infowindow, map, iconSmart, contents, bounds){ |
88 |
70 |
|
function success(response){ |
89 |
71 |
|
if (response){ |
|
@@ -177,69 +159,84 @@ |
177 |
159 |
|
|
178 |
160 |
|
|
179 |
161 |
|
function TipControl(controlList, tipologies, markers, searchedMarker, listLocals, map) { |
180 |
|
- |
controlList.style.padding = '0'; |
181 |
|
- |
var controlUI; |
182 |
|
- |
var controlBackgroundUI; |
183 |
|
- |
//var controlAllMarkerUI; |
184 |
|
- |
|
185 |
|
- |
if (tipologies){ |
186 |
|
- |
/*controlBackgroundUI = document.createElement('div'); |
187 |
|
- |
controlBackgroundUI.className = "li-background"; |
188 |
|
- |
controlAllMarkerUI = document.createElement('li'); |
189 |
|
- |
controlAllMarkerUI.className = "all-markers"; |
190 |
|
- |
controlAllMarkerUI.innerHTML = "<p><b>Tutti</b></p>"; |
191 |
|
- |
controlAllMarkerUI.style.textAlign = 'center'; |
192 |
|
- |
controlAllMarkerUI.style.backgroundColor = '#fff'; |
193 |
|
- |
controlBackgroundUI.appendChild(controlAllMarkerUI); |
194 |
|
- |
controlList.appendChild(controlBackgroundUI);*/ |
195 |
|
- |
for(var i = 0; i<tipologies.length; i++){ |
196 |
|
- |
controlBackgroundUI = document.createElement('div') |
197 |
|
- |
controlBackgroundUI.className = "li-background"; |
198 |
|
- |
controlUI = document.createElement('li'); |
199 |
|
- |
controlUI.style.backgroundColor = '#fff'; |
200 |
|
- |
controlUI.style.textAlign = 'center'; |
201 |
|
- |
controlUI.title = tipologies[i].tipologia; |
202 |
|
- |
controlUI.className = tipologies[i].id; |
203 |
|
- |
controlBackgroundUI.appendChild(controlUI); |
204 |
|
- |
controlList.appendChild(controlBackgroundUI); |
205 |
|
- |
var controlText = document.createElement('p'); |
206 |
|
- |
controlText.innerHTML = '<b>' + tipologies[i].tipologia + '</b>'; |
207 |
|
- |
controlUI.appendChild(controlText); |
208 |
|
- |
|
209 |
|
- |
google.maps.event.addDomListener(controlBackgroundUI, 'mouseover', function(){ |
210 |
|
- |
$(this).addClass("hover"); |
211 |
|
- |
$(this).find('p').addClass("hover"); |
212 |
|
- |
}); |
213 |
|
- |
|
214 |
|
- |
google.maps.event.addDomListener(controlBackgroundUI, 'mouseout', function(){ |
215 |
|
- |
$(this).removeClass("hover"); |
216 |
|
- |
$(this).find('p').removeClass("hover"); |
217 |
|
- |
}); |
218 |
|
- |
|
219 |
|
- |
// Setup click-event listener: filter marker by tipology |
220 |
|
- |
google.maps.event.addDomListener(controlUI, 'click', function() { |
221 |
|
- |
var that = this; |
222 |
|
- |
var currents = []; |
223 |
|
- |
if(markers.length > 0){ |
224 |
|
- |
for (var elem in listLocals){ |
225 |
|
- |
if (parseInt(that.getAttribute("class")) == listLocals[elem].tipologia){ |
226 |
|
- |
current = listLocals[elem].nomelocale; |
227 |
|
- |
currents.push(current); |
|
162 |
+ |
controlList.style.padding = '0'; |
|
163 |
+ |
var controlUI; |
|
164 |
+ |
var controlBackgroundUI; |
|
165 |
+ |
var allTip = {id: "-1001", tipologia: "Tutti"}; |
|
166 |
+ |
//tipologies.unshift(allTip); |
|
167 |
+ |
var ExTipologies = getExistingTip(tipologies, listLocals); |
|
168 |
+ |
ExTipologies.unshift(allTip); |
|
169 |
+ |
|
|
170 |
+ |
if (tipologies){ |
|
171 |
+ |
for(var i = 0; i<ExTipologies.length; i++){ |
|
172 |
+ |
controlBackgroundUI = document.createElement('div'); |
|
173 |
+ |
controlBackgroundUI.className = "li-background"; |
|
174 |
+ |
controlUI = document.createElement('li'); |
|
175 |
+ |
controlUI.style.backgroundColor = '#fff'; |
|
176 |
+ |
controlUI.style.textAlign = 'center'; |
|
177 |
+ |
controlUI.title = ExTipologies[i].tipologia; |
|
178 |
+ |
controlUI.className = ExTipologies[i].id; |
|
179 |
+ |
controlBackgroundUI.appendChild(controlUI); |
|
180 |
+ |
controlList.appendChild(controlBackgroundUI); |
|
181 |
+ |
var controlText = document.createElement('p'); |
|
182 |
+ |
controlText.innerHTML = '<b>' + ExTipologies[i].tipologia + '</b>'; |
|
183 |
+ |
controlUI.appendChild(controlText); |
|
184 |
+ |
|
|
185 |
+ |
google.maps.event.addDomListener(controlBackgroundUI, 'mouseover', function(){ |
|
186 |
+ |
$(this).addClass("hover"); |
|
187 |
+ |
$(this).find('p').addClass("hover"); |
|
188 |
+ |
}); |
|
189 |
+ |
|
|
190 |
+ |
google.maps.event.addDomListener(controlBackgroundUI, 'mouseout', function(){ |
|
191 |
+ |
$(this).removeClass("hover"); |
|
192 |
+ |
$(this).find('p').removeClass("hover"); |
|
193 |
+ |
}); |
|
194 |
+ |
|
|
195 |
+ |
// Setup click-event listener: filter marker by tipology |
|
196 |
+ |
google.maps.event.addDomListener(controlUI, 'click', function() { |
|
197 |
+ |
var that = this; |
|
198 |
+ |
var currents = []; |
|
199 |
+ |
|
|
200 |
+ |
if(markers.length > 0){ |
|
201 |
+ |
for (var elem in listLocals){ |
|
202 |
+ |
if (parseInt(that.getAttribute("class")) == listLocals[elem].tipologia){ |
|
203 |
+ |
current = listLocals[elem].nomelocale; |
|
204 |
+ |
currents.push(current); |
|
205 |
+ |
} |
228 |
206 |
|
} |
|
207 |
+ |
|
|
208 |
+ |
markers.forEach(function(marker) { |
|
209 |
+ |
if(marker.title != searchedMarker && that.textContent != "Tutti" && $.inArray(marker.title, currents) == -1) |
|
210 |
+ |
marker.setMap(null); |
|
211 |
+ |
else if(marker.title != searchedMarker && (that.textContent == "Tutti" || $.inArray(marker.title, currents) != -1)){ |
|
212 |
+ |
marker.setMap(map); |
|
213 |
+ |
marker.setVisible(true); |
|
214 |
+ |
} |
|
215 |
+ |
}); |
229 |
216 |
|
} |
230 |
|
- |
|
231 |
|
- |
markers.forEach(function(marker) { |
232 |
|
- |
if(marker.title != searchedMarker && $.inArray(marker.title, currents) == -1) |
233 |
|
- |
marker.setMap(null); |
234 |
|
- |
else if(marker.title != searchedMarker && $.inArray(marker.title, currents) != -1){ |
235 |
|
- |
marker.setMap(map); |
236 |
|
- |
marker.setVisible(true); |
237 |
|
- |
} |
238 |
|
- |
}); |
239 |
|
- |
} |
240 |
|
- |
}); |
|
217 |
+ |
}); |
|
218 |
+ |
} |
|
219 |
+ |
} |
|
220 |
+ |
} |
|
221 |
+ |
|
|
222 |
+ |
function getExistingTip(tipologies, locals){ |
|
223 |
+ |
var exTip = []; |
|
224 |
+ |
var tip = []; |
|
225 |
+ |
for (var elem in locals){ |
|
226 |
+ |
exTip.push(locals[elem].tipologia); |
241 |
227 |
|
} |
242 |
|
- |
} |
|
228 |
+ |
|
|
229 |
+ |
var uniqueId = []; |
|
230 |
+ |
$.each(exTip, function(i, el){ |
|
231 |
+ |
if($.inArray(el, uniqueId) === -1) uniqueId.push(el); |
|
232 |
+ |
}); |
|
233 |
+ |
|
|
234 |
+ |
for (var i = 0; i<tipologies.length; i++){ |
|
235 |
+ |
if($.inArray(tipologies[i].id, uniqueId) != -1) |
|
236 |
+ |
tip.push(tipologies[i]); |
|
237 |
+ |
} |
|
238 |
+ |
|
|
239 |
+ |
return tip; |
243 |
240 |
|
} |
244 |
241 |
|
|
245 |
242 |
|
|