var WifiHotspotsJs=function(){function a(){for(var f=t.getBounds(),r=f.getNorthEast(),u=f.getSouthWest(),o={__RequestVerificationToken:e,northEastLatitude:r.lat(),northEastLongitude:r.lng(),southWestLatitude:u.lat(),southWestLongitude:u.lng()};i.length;)i.pop().setMap(null);$.post(n.getHotspotsClusterUrl,o,function(n){var f,e;c(n.HotspotCount);var o=new google.maps.LatLng(r.lat(),r.lng()),s=new google.maps.LatLng(r.lat(),u.lng()),h=google.maps.geometry.spherical.computeDistanceBetween(o,s)/14;n.ClusterList!=null&&n.ClusterList.length>0&&(e=Math.max.apply(null,n.ClusterList.map(function(n){return n.Size})),$.each(n.ClusterList,function(n,r){f=new google.maps.Circle({strokeColor:"#0bc",strokeOpacity:.8,strokeWeight:2,fillColor:"#0cd",fillOpacity:.35,map:t,center:{lat:r.Latitude,lng:r.Longitude},radius:Math.sqrt(r.Size/e)*h});i.push(f)}))})}function v(r,u){f=[];var o={__RequestVerificationToken:e,lat:r.lat(),lng:r.lng(),miles:u};$.post(n.getNearbyHotspotsUrl,o,function(r){for(var u,e;i.length;)i.pop().setMap(null);u=r.HotspotList!=null&&r.HotspotList.length>0?r.HotspotList.length:0;u>0&&($.each(r.HotspotList,function(r,u){f[r]=u;e=new google.maps.Marker({position:{lat:u.Latitude,lng:u.Longitude},map:t,title:u.MapSearchName,icon:n.markerImage});google.maps.event.addListener(e,"click",function(){var r=b(u),t;for($(n.hotspotSelectedDivId).html(r),t=0;t<i.length;t++)i[t].setIcon(n.markerImage),i[t].setZIndex(100);this.setIcon(n.markerSelectedImage);this.setZIndex(101)});i.push(e)}),c(u),h(!0))})}var e=$("input[name=__RequestVerificationToken]").val(),u="hidden",n={},t,i=[],f=[],r=null,o=0,y=function(t){n=$.extend(!0,{nearbyHotspotsMilesLimit:1.5,hotspotMapId:"hotspotMap",center:{lat:51.6,lng:-.5},zoom:13,minZoom:9,searchBoxInputId:"pac-input",getHotspotsClusterUrl:null,getNearbyHotspotsUrl:null,lblWifiTranslation:"Wi-Fi:",markerImage:"/content/img/map-marker-32x32.png",markerSelectedImage:"/content/img/map-marker-32x32-active.png",myLocationImage:"/content/img/my-location-32x32.svg",hotspotCountDivId:"#hotspot-count-div",hotspotSelectedDivId:"#hotspot-selected-div",hotspotsDivId:"#hotspots-div",viewMoreBtnId:"#view-more",lblHotspotsInThisArea:"Hotspots in this area",lblSelectedHotspot:"Selected hotspot",lblHotspotName:"Hotspot name",lblAddress:"Address",lblDistance:"Distance",btnGetDirections:"Get directions"},t);s();$(document).on("click",n.viewMoreBtnId,function(){h()})},s=function(){t=new google.maps.Map(document.getElementById(n.hotspotMapId),{center:n.center,zoom:n.zoom,minZoom:n.minZoom,styles:k});navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(i){var u={lat:i.coords.latitude,lng:i.coords.longitude};t.setCenter(u);r=u;new google.maps.Marker({position:{lat:u.lat,lng:u.lng},map:t,icon:n.myLocationImage})},function(){});var u=document.getElementById(n.searchBoxInputId),i=new google.maps.places.SearchBox(u);t.addListener("bounds_changed",function(){i.setBounds(t.getBounds())});i.addListener("places_changed",function(){var r=i.getPlaces(),n;r.length!=0&&(n=new google.maps.LatLngBounds,r.forEach(function(t){t.geometry.viewport?n.union(t.geometry.viewport):n.extend(t.geometry.location)}),t.fitBounds(n))});t.addListener("idle",function(){p();var i=t.getCenter(),u=t.getBounds().getNorthEast(),r=google.maps.geometry.spherical.computeDistanceBetween(u,i)/1e3*.621371;r>n.nearbyHotspotsMilesLimit?a():v(i,r)})},p=function(){$(n.hotspotsDivId).html(null);$(n.hotspotSelectedDivId).html(null);$(n.hotspotCountDivId).html(null);$(n.viewMoreBtnId).addClass(u)},h=function(t){var s,i,r,e,h;for($(n.viewMoreBtnId).removeClass(u),s=t?0:o+1,i=0;i<4;i++){if(r=s+i,e=f[r],e==null){$(n.viewMoreBtnId).addClass(u);break}h=l(e);$(n.hotspotsDivId).append(h);o=r}},c=function(t){var i=t>0?w(t):null;$(n.hotspotCountDivId).html(i)},w=function(t){return t.toLocaleString("en")+" "+n.lblHotspotsInThisArea},b=function(t){return'<div class="panel-group panel-body bg-green color-white"><h4>'+n.lblSelectedHotspot+"<\/h4><hr>"+l(t,!0)+"<\/div>"},l=function(t,i){return"<p><strong>"+n.lblHotspotName+"<\/strong> "+t.SSID+"<\/p><p><strong>"+n.lblAddress+"<\/strong> "+t.SiteAddress+"<\/p>"+(r!=null?"<p><strong>"+n.lblDistance+"<\/strong> "+d(t)+"&nbsp;km<\/p>":"")+'<a href="https://www.google.com/maps?saddr=My+Location&daddr='+t.Latitude+","+t.Longitude+'" class="btn btn-sm btn-blue" target="_blank" rel="noopener"><i class="zmdi zmdi-navigation"><\/i>&nbsp;'+n.btnGetDirections+"<\/a>"+(i?"":"<hr>")},k=[],d=function(n){if(r!=null){var i=g(r.lat,r.lng,n.Latitude,n.Longitude),t=i/1e3;return t>1?Math.round(t):t.toFixed(2)}return null},g=function(n,t,i,r){var u=new google.maps.LatLng(n,t),f=new google.maps.LatLng(i,r);return google.maps.geometry.spherical.computeDistanceBetween(u,f)};return{initMap:s,initialize:y}}()