var PGC_LiveMap={map:null,mapLayers:null,icons:{},geocacheMarkers:{},correctedCoordinates:{},correctedCoordinatesIsInUse:null,params:null,completedGeocacheTiles:{},geocachesInTiles:{},loadingRectangles:{},ajax_GetGeocachesWithinBoundingBox:{},mapFilter:null,saveMapFilter:!1,sidebar:null,myData:null,alerts:{tooMany:null,failedToRetrieveData:null},maxVisible:2500,getGeocachesWithinBoundingBoxQueue:{},numGetGeocachesWithinBoundingBoxRunning:0,maxGetGeocachesWithinBoundingBoxThreads:8,liveMapEnabled:!0,InitiateMap:function(e,a,i){void 0===a&&(a={}),void 0===i&&(i={isPaying:0}),PGC_LiveMap.params=i,PGC_LiveMap.correctedCoordinatesIsInUse=Boolean(PGC_LiveMap.params.isPaying),void 0!==PGC_LiveMap.params.geocacheLimit&&(PGC_LiveMap.maxVisible=PGC_LiveMap.params.geocacheLimit);var t=PGC_LiveMap.GetHashLocation();!1!==t&&(a.center=t.center,a.zoom=t.zoom),PGC_LiveMap.Log("Creating map object"),PGC_LiveMap.map=new L.Map(e,a);var o={OpenStreetMap:L.tileLayer.provider("OpenStreetMap.Mapnik"),"OpenStreetMap German Style":L.tileLayer.provider("OpenStreetMap.DE"),"Thunderforest OpenCycleMap":new L.TileLayer("//mapproxy.project-gc.com/tiles/1.0.0/TF-ocm/webmercator/{z}/{x}/{y}.png",{minZoom:1,maxZoom:22}),"Thunderforest Transport":new L.TileLayer("//mapproxy.project-gc.com/tiles/1.0.0/TF-transport/webmercator/{z}/{x}/{y}.png",{minZoom:1,maxZoom:22}),"Thunderforest Landscape":new L.TileLayer("//mapproxy.project-gc.com/tiles/1.0.0/TF-landscape/webmercator/{z}/{x}/{y}.png",{minZoom:1,maxZoom:22}),"Esri WorldStreetMap":L.tileLayer.provider("Esri.WorldStreetMap"),"Esri DeLorme":L.tileLayer.provider("Esri.DeLorme"),"Esri WorldTopoMap":L.tileLayer.provider("Esri.WorldTopoMap"),"Esri WorldImagery":L.tileLayer.provider("Esri.WorldImagery"),"Eniro street":new L.TileLayer("//map.eniro.com/geowebcache/service/tms1.0.0/map/{z}/{x}/{y}.png",{tms:!0}),"Eniro aerial":new L.TileLayer("//map.eniro.com/geowebcache/service/tms1.0.0/aerial/{z}/{x}/{y}.jpeg",{tms:!0}),"Eniro nautical":new L.TileLayer("//map.eniro.com/geowebcache/service/tms1.0.0/nautical/{z}/{x}/{y}.png",{tms:!0})};i.isPaying&&PGC_LiveMap.map.addControl(new L.Control.pgcGoogleMapsControl({map:map})),void 0!==PGC_LiveMap.params.extraTileLayers&&$.each(PGC_LiveMap.params.extraTileLayers,function(e,a){o[e]=new L.TileLayer(a)});PGC_LiveMap.Log("Adding zoom controls"),L.control.scale().addTo(PGC_LiveMap.map),PGC_LiveMap.Log("Adding measure tool"),L.Control.measureControl().addTo(PGC_LiveMap.map),PGC_LiveMap.Log("Adding minimap"),PGC_LiveMap.Log("Adding coordinates"),L.control.coordinates({position:"bottomleft",decimals:2,decimalSeperator:".",useLatLngOrder:!0,labelFormatterLat:function(e){return DDD2DDMM("latitude",e)},labelFormatterLng:function(e){return DDD2DDMM("longitude",e)}}).addTo(PGC_LiveMap.map),PGC_LiveMap.Log("Adding sidebar"),PGC_LiveMap.sidebar=L.control.sidebar("map_sidebar").addTo(PGC_LiveMap.map),PGC_LiveMap.map.addControl(new L.Control.Search({url:"//nominatim.openstreetmap.org/search?format=json&q={s}",jsonpParam:"json_callback",propertyName:"display_name",propertyLoc:["lat","lon"],circleLocation:!1,markerLocation:!1,autoType:!1,autoCollapse:!0,minLength:2,zoom:14})),L.control.locate({position:"topleft",drawCircle:!0,follow:!1,keepCurrentZoomLevel:!0,remainActive:!1,markerClass:L.circleMarker,metric:!0,showPopup:!1,locateOptions:{enableHighAccuracy:!0},icon:"icon-location"}).addTo(PGC_LiveMap.map),PGC_LiveMap.Log("Adding layers"),void 0!==PGC_LiveMap.params.defaultTileLayer&&void 0!==o[PGC_LiveMap.params.defaultTileLayer]?PGC_LiveMap.map.addLayer(o[PGC_LiveMap.params.defaultTileLayer]):PGC_LiveMap.map.addLayer(o.OpenStreetMap),PGC_LiveMap.mapLayers=new L.Control.Layers(o,{}),PGC_LiveMap.map.addControl(PGC_LiveMap.mapLayers),PGC_LiveMap.Log("Binding popup open event"),PGC_LiveMap.map.on("popupopen",function(){PGC_LiveMap.BindVirtualGPS()}),$("#map > div.leaflet-control-container").after('
'+HtmlEncode(PGC_LiveMap.params.strings.liveEnabled)+"
"),$("#liveMapButton").click(function(){PGC_LiveMap.LiveMapButtonClick()}),PGC_LiveMap.Log("Fetching user data"),PGC_LiveMap.map.spin(!0);var r=PGC_LiveMap.AddAlert("info",PGC_LiveMap.params.strings.preparingData);PGC_LiveMap.myData={},$.when($.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"myOwnedCacheIds"},success:function(e){PGC_LiveMap.myData.myOwnedCacheIds=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"myFoundCacheIds"},success:function(e){PGC_LiveMap.myData.myFoundCacheIds=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"myNotedChallenges"},success:function(e){PGC_LiveMap.myData.myNotedChallenges=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"cacheIdsInCurrentVGPS"},success:function(e){PGC_LiveMap.myData.cacheIdsInCurrentVGPS=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"challengeCheckerStatus"},success:function(e){PGC_LiveMap.myData.challengeCheckerStatus=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"cacheIdsWithCacheNotes"},success:function(e){PGC_LiveMap.myData.cacheIdsWithCacheNotes=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"myCorrectedCoordinates"},success:function(e){PGC_LiveMap.myData.myCorrectedCoordinates=e}}),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"GetMyData",part:"savedFilters"},success:function(e){PGC_LiveMap.myData.savedFilters=e}})).then(function(){PGC_LiveMap.Log("Received user data"),PGC_LiveMap.myData.myOwnedCacheIds=ArrayFlipAndFillValues(PGC_LiveMap.myData.myOwnedCacheIds,!0),PGC_LiveMap.myData.myFoundCacheIds=ArrayFlipAndFillValues(PGC_LiveMap.myData.myFoundCacheIds,!0),PGC_LiveMap.myData.myNotedChallenges=ArrayFlipAndFillValues(PGC_LiveMap.myData.myNotedChallenges,!0),PGC_LiveMap.myData.cacheIdsInCurrentVGPS=ArrayFlipAndFillValues(PGC_LiveMap.myData.cacheIdsInCurrentVGPS,!0),PGC_LiveMap.myData.cacheIdsWithCacheNotes=ArrayFlipAndFillValues(PGC_LiveMap.myData.cacheIdsWithCacheNotes,!0),!1!==PGC_LiveMap.myData.savedFilters&&PGC_LiveMap.ParseSavedFilters(),PGC_LiveMap.RemoveAlert(r),PGC_LiveMap.map.spin(!1),PGC_LiveMap.map.addEventListener("load moveend zoomend resize",PGC_LiveMap.GetGeocachesIfLiveEnabled),PGC_LiveMap.map.addEventListener("load moveend zoomend",PGC_LiveMap.AddHashTag),PGC_LiveMap.GetGeocaches(),PGC_LiveMap.AddHashTag()}).fail(function(){PGC_LiveMap.Log("Error receiving user data"),PGC_LiveMap.RemoveAlert(r),PGC_LiveMap.alerts.failedToRetrieveData=PGC_LiveMap.AddAlert("danger",PGC_LiveMap.params.strings.failedToRetrieveData),PGC_LiveMap.map.spin(!1)})},GetHashParameters:function(){var e={},a=location.hash.substring(1);if(0==a.length)return e;for(var i=a.split(";"),t=0;tl)&&(l=a[2]),(null===c||a[1]>c)&&(c=a[3])});i={cmd:"GetNumberOfGeocachesWithinGeocacheTiles",minLon:s,minLat:n,maxLon:l,maxLat:c,filters:JSON.stringify(PGC_LiveMap.mapFilter),saveFilters:!0===PGC_LiveMap.saveMapFilter?1:0};return $.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:i,success:function(e){if(e.totalGeocaches<=PGC_LiveMap.maxVisible){var a=PGC_LiveMap.GetNumberOfGeocachesInMemory();if(a+e.totalGeocaches>PGC_LiveMap.maxVisible)for(var i in PGC_LiveMap.completedGeocacheTiles)if(void 0===o[i]&&(PGC_LiveMap.RemoveTile(i),PGC_LiveMap.GetNumberOfGeocachesInMemory()+e.totalGeocaches<=PGC_LiveMap.maxVisible))break;null!==PGC_LiveMap.alerts.tooMany&&(PGC_LiveMap.RemoveAlert(PGC_LiveMap.alerts.tooMany),PGC_LiveMap.alerts.tooMany=null),$.each(o,function(e,a){PGC_LiveMap.Log("Tile "+e+": "+a),void 0!==PGC_LiveMap.completedGeocacheTiles[e]?PGC_LiveMap.Log("Geocaches for tile "+e+" already fetched"):void 0!==PGC_LiveMap.ajax_GetGeocachesWithinBoundingBox[e]?PGC_LiveMap.Log("Fetch for tile "+e+" already in progress"):void 0!==PGC_LiveMap.getGeocachesWithinBoundingBoxQueue[e]?PGC_LiveMap.Log("Tile "+e+" already in queue"):(PGC_LiveMap.Log("Adding tile "+e+" to queue"),PGC_LiveMap.AddGeocacheTileToQueue(e,a))}),PGC_LiveMap.RunGetGeocachesWithinBoundingBoxQueue()}else PGC_LiveMap.Log("Too many geocaches in visible area, informing user"),null===PGC_LiveMap.alerts.tooMany&&(PGC_LiveMap.alerts.tooMany=PGC_LiveMap.AddAlert("warning",PGC_LiveMap.params.strings.tooMany))},error:function(){null===PGC_LiveMap.alerts.failedToRetrieveData&&(PGC_LiveMap.alerts.failedToRetrieveData=PGC_LiveMap.AddAlert("danger",PGC_LiveMap.params.strings.failedToRetrieveData)),PGC_LiveMap.map.spin(!1)}}),!0},AddHashTag:function(e){var a=PGC_LiveMap.map.getCenter(),i=PGC_LiveMap.map.getZoom(),t=Math.round10(a.lat,-5),a=Math.round10(a.lng,-5);location.hash="c="+t+","+a+";z="+i},CalculateGeocacheTilesFromBoundingBox:function(e,a){var i={},a=a.split(",");if(14<=e)for(var t=Math.floor10(a[0],-2),o=Math.floor10(a[1],-2),r=Math.ceil10(a[2],-2),n=Math.ceil10(a[3],-2),c=t;c<=r;c+=.01)for(var s=o;s<=n;s+=.01){var l=Math.round10(c,-2),p=Math.round10(s,-2),d=Math.round10(c+.01,-2),v=Math.round10(s+.01,-2);i[p+","+l+":"+e]=[l,p,d,v]}else if(10<=e)for(t=Math.floor10(a[0],-1),o=Math.floor10(a[1],-1),r=Math.ceil10(a[2],-1),n=Math.ceil10(a[3],-1),c=t;c<=r;c+=.1)for(s=o;s<=n;s+=.1){l=Math.round10(c,-1),p=Math.round10(s,-1),d=Math.round10(c+.1,-1),v=Math.round10(s+.1,-1);i[p+","+l+":"+e]=[l,p,d,v]}else for(t=Math.floor(a[0]),o=Math.floor(a[1]),r=Math.ceil(a[2]),n=Math.ceil(a[3]),c=t;c<=r;c+=1)for(s=o;s<=n;s+=1){l=Math.round(c),p=Math.round(s),d=Math.round(c+1),v=Math.round(s+1);i[p+","+l+":"+e]=[l,p,d,v]}return i},GetGeocachesWithinBoundingBox:function(c,a,i){void 0===i&&(i=0,PGC_LiveMap.geocachesInTiles[c]=[]),PGC_LiveMap.Log("GetGeocachesWithinBoundingBox "+c+" (page "+i+")"),PGC_LiveMap.map.spin(!0);var e={cmd:"GetGeocachesWithinBoundingBox",boundingBox:a,page:i,filters:JSON.stringify(PGC_LiveMap.mapFilter),saveFilters:!0===PGC_LiveMap.saveMapFilter?1:0},e=$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:e,success:function(e){PGC_LiveMap.Log("GetGeocachesWithinBoundingBox() "+c+": success"),$.each(e.geocaches,function(e,a){var i,t,o,r,n;void 0===PGC_LiveMap.geocacheMarkers[e]&&(i=''+a.gccode+" - "+a.name+"
\t\t\t\t\t\t"+a.type+" / "+a.size+" / "+a.difficulty+" / "+a.terrain+"
\t\t\t\t\t\t"+a.favorite_points+" FP ("+Math.round(a.favorite_points_pct)+"%, "+Math.round(a.favorite_points_wilson)+"W)",PGC_LiveMap.params.isPaying&&(!1===PGC_LiveMap.myData.cacheIdsInCurrentVGPS?i+='':PGC_LiveMap.myData.cacheIdsInCurrentVGPS[e]?i+='':i+=''),t={},1==a.disabled&&(t.disabled=!0),1==a.archived&&(t.archived=!0),PGC_LiveMap.myData.myOwnedCacheIds[e]&&(t.isOwned=!0),PGC_LiveMap.myData.myFoundCacheIds[e]&&(t.isFound=!0),PGC_LiveMap.myData.myNotedChallenges[e]&&(t.isNoted=!0),!1!==PGC_LiveMap.myData.cacheIdsInCurrentVGPS&&PGC_LiveMap.myData.cacheIdsInCurrentVGPS[e]&&(t.inVirtualGPS=!0),PGC_LiveMap.myData.challengeCheckerStatus[e]&&"success"==PGC_LiveMap.myData.challengeCheckerStatus[e]&&(t.checkerSuccess=!0),PGC_LiveMap.myData.challengeCheckerStatus[e]&&"fail"==PGC_LiveMap.myData.challengeCheckerStatus[e]&&(t.checkerFail=!0),PGC_LiveMap.myData.challengeCheckerStatus[e]&&"checkerExists"==PGC_LiveMap.myData.challengeCheckerStatus[e]&&(t.checkerExists=!0),PGC_LiveMap.myData.myCorrectedCoordinates[e]&&(t.hasCorrected=!0),PGC_LiveMap.myData.cacheIdsWithCacheNotes[e]&&(t.hasCacheNote=!0),n=PGC_LiveMap.GetCacheIcon(a.type,t),o=a.latitude,r=a.longitude,1==PGC_LiveMap.correctedCoordinatesIsInUse&&PGC_LiveMap.myData.myCorrectedCoordinates[e]&&(o=PGC_LiveMap.myData.myCorrectedCoordinates[e].latitude,r=PGC_LiveMap.myData.myCorrectedCoordinates[e].longitude),PGC_LiveMap.correctedCoordinates.cacheId={latitude:a.latitude,longitude:a.longitude,corrected_latitude:a.corrected_latitude,corrected_longitude:a.corrected_longitude},(n=new L.Marker(new L.LatLng(o,r),{icon:n}).addTo(PGC_LiveMap.map)).bindLabel(a.gccode+" - "+a.name),n.bindPopup(i),PGC_LiveMap.geocacheMarkers[e]={cacheType:a.type,iconParams:t,marker:n},PGC_LiveMap.geocacheMarkers[e].marker=n,PGC_LiveMap.geocachesInTiles[c].push(e))}),e.hasMore?PGC_LiveMap.GetGeocachesWithinBoundingBox(c,a,i+1):(PGC_LiveMap.map.removeLayer(PGC_LiveMap.loadingRectangles[c]),PGC_LiveMap.completedGeocacheTiles[c]=PGC_LiveMap.geocachesInTiles[c].length),PGC_LiveMap.GetNumberOfGeocachesInMemory(),PGC_LiveMap.numGetGeocachesWithinBoundingBoxRunning--,PGC_LiveMap.map.spin(!1),delete PGC_LiveMap.ajax_GetGeocachesWithinBoundingBox[c],setTimeout(function(){PGC_LiveMap.RunGetGeocachesWithinBoundingBoxQueue()},100)},error:function(e){PGC_LiveMap.Log("GetGeocachesWithinBoundingBox() "+c+": error"),PGC_LiveMap.numGetGeocachesWithinBoundingBoxRunning--,PGC_LiveMap.map.spin(!1),delete PGC_LiveMap.ajax_GetGeocachesWithinBoundingBox[c]}});PGC_LiveMap.ajax_GetGeocachesWithinBoundingBox[c]=e},GetCacheIcon:function(e,a){var i=[e,a=void 0===a?{}:a],i=CRC32.str(JSON.stringify(i));if(void 0!==PGC_LiveMap.icons[i])return PGC_LiveMap.icons[i];PGC_LiveMap.Log("Creating new cache icon");e="//cdn2.project-gc.com/dimages/pgc-cache-icon.php?type="+e;void 0!==a.iconBackground&&(e=e+"&color="+a.iconBackground),void 0!==a.isOwned&&a.isOwned&&(e+="&isOwned"),void 0!==a.isFound&&a.isFound&&(e+="&isFound"),void 0!==a.isNoted&&a.isNoted&&(e+="&isNoted"),void 0!==a.checkerSuccess&&a.checkerSuccess&&(e+="&checkerSuccess"),void 0!==a.checkerFail&&a.checkerFail&&(e+="&checkerFail"),void 0!==a.checkerExists&&a.checkerExists&&(e+="&checkerExists"),void 0!==a.hasCorrected&&a.hasCorrected&&(e+="&hasCorrected"),void 0!==a.hasCacheNote&&a.hasCacheNote&&(e+="&hasCacheNote"),void 0!==a.inVirtualGPS&&a.inVirtualGPS&&(e+="&inVirtualGPS"),void 0!==a.colorBlind&&a.colorBlind&&(e+="&cb"),void 0!==a.archived&&a.archived?e+="&stroke=2":void 0!==a.disabled&&a.disabled&&(e+="&fade");e=new(e=L.Icon.extend({options:{iconUrl:e,iconSize:new L.Point(25,26),iconAnchor:new L.Point(13,26),popupAnchor:new L.Point(1,-26)}}));return PGC_LiveMap.icons[i]=e},RemoveAllGeocacheMarkers:function(){PGC_LiveMap.Log("Stopping all ajax calls and removing all markers"),$.each(PGC_LiveMap.ajax_GetGeocachesWithinBoundingBox,function(e,a){PGC_LiveMap.numGetGeocachesWithinBoundingBoxRunning--,delete PGC_LiveMap.getGeocachesWithinBoundingBoxQueue[e],a.abort()}),$.each(PGC_LiveMap.geocacheMarkers,function(e,a){PGC_LiveMap.map.removeLayer(a.marker)}),PGC_LiveMap.geocacheMarkers={},PGC_LiveMap.completedGeocacheTiles={},PGC_LiveMap.geocachesInTiles={}},AddAlert:function(e,a){var i="mapAlert_"+Date.now();PGC_LiveMap.Log("Creating alert with id "+i);a='\t\t\t\t\t\t\t\t\t\t\t'+a+"\t\t\t
\t\t";return $("#livemap_alerts").append(a),i},RemoveAlert:function(e){PGC_LiveMap.Log("Removing alert with id "+e),$("#"+e).remove()},SetFilters:function(e){PGC_LiveMap.Log("Setting filters"),PGC_LiveMap.mapFilter=e,PGC_LiveMap.saveMapFilter=PGC_LiveMap.params.saveFilters,$.isEmptyObject(e)?$("#map_sidebar ul.sidebar-tabs li[data-sidebarTab=filter]").removeClass("filtered"):$("#map_sidebar ul.sidebar-tabs li[data-sidebarTab=filter]").addClass("filtered")},BindVirtualGPS:function(){if(!1===PGC_LiveMap.myData.cacheIdsInCurrentVGPS)return PGC_LiveMap.Log("BindVirtualGPS() No VGPS selected"),!1;PGC_LiveMap.Log("Binding for VGPS"),$(".addtovgps").off("click"),$(".removefromvgps").off("click"),$(".addtovgps").click(function(){var a=$(this),i=$(this).attr("data-cacheid"),e=[];e.push(i);return $(a).effect("transfer",{to:$("#menu_virtual_gps")},1e3,function(){$(a).attr("src",PGC_LiveMap.params.vgps.removeFromVgpsSrc),$(a).attr("title",PGC_LiveMap.params.strings.removeFromVGPS),$(a).removeClass("addtovgps"),$(a).addClass("removefromvgps"),PGC_LiveMap.geocacheMarkers[i].marker.setPopupContent($(a).html()),PGC_LiveMap.geocacheMarkers[i].iconParams.inVirtualGPS=!0;var e=PGC_LiveMap.GetCacheIcon(PGC_LiveMap.geocacheMarkers[i].cacheType,PGC_LiveMap.geocacheMarkers[i].iconParams);PGC_LiveMap.geocacheMarkers[i].marker.setIcon(e),PGC_LiveMap.myData.cacheIdsInCurrentVGPS[i]=!0,"false"===PGC_LiveMap.myData.cacheIdsInCurrentVGPS&&(PGC_LiveMap.myData.cacheIdsInCurrentVGPS=!1),PGC_LiveMap.BindVirtualGPS()}),$.ajax({url:"/ajax/virtualgps.php",dataType:"JSON",type:"POST",data:{cmd:"addToCurrentList",cacheIds:e,sourcePage:"LiveMap",sourceHref:"/LiveMap"},success:function(e){$("#virtualgps_selected_name").html(e.listName),$("#virtualgps_selected_count").html(e.cacheCount)},error:function(e){}}),!0}),$(".removefromvgps").click(function(){var a=$(this),i=$(this).attr("data-cacheid"),e=($(this).attr("data-sectionid"),[]);e.push(i),$(a).effect({effect:"fade",duration:1e3,complete:function(){$(a).effect("fade","slow",1e3),$(a).attr("src",PGC_LiveMap.params.vgps.addToVgpsSrc),$(a).attr("title",PGC_LiveMap.params.strings.addToVGPS),$(a).removeClass("removefromvgps"),$(a).addClass("addtovgps"),PGC_LiveMap.geocacheMarkers[i].marker.setPopupContent($(a).html()),delete PGC_LiveMap.geocacheMarkers[i].iconParams.inVirtualGPS;var e=PGC_LiveMap.GetCacheIcon(PGC_LiveMap.geocacheMarkers[i].cacheType,PGC_LiveMap.geocacheMarkers[i].iconParams);PGC_LiveMap.geocacheMarkers[i].marker.setIcon(e),delete PGC_LiveMap.myData.cacheIdsInCurrentVGPS[i],PGC_LiveMap.BindVirtualGPS()}}),$.ajax({url:"/ajax/virtualgps.php",dataType:"JSON",type:"POST",data:{cmd:"removeFromCurrentList",cacheIds:e},success:function(e){$("#virtualgps_selected_name").html(e.listName),$("#virtualgps_selected_count").html(e.cacheCount)},error:function(e){}})})},GetFiltersFromForm:function(){PGC_LiveMap.Log("Parsing form filters");var i,t={};return $("#map_sidebar fieldset[data-groupname=roadtrip15] input:checked").each(function(e,a){t[$(this).attr("name")]="yes"}),$("#map_sidebar fieldset[data-groupname=standardFilters] input:checked").each(function(e,a){t[$(this).attr("name")]="yes"}),0<$("#livemap_filter_cacheTypes li img.exclude").length&&(i=[],$("#livemap_filter_cacheTypes li img:not(.exclude)").each(function(e,a){i.push($(this).attr("alt"))}),t.cacheTypes=i),$("#livemap_filter_cacheTypes li img.exclude"),$("#livemap_filter_cacheTypes li img:not(.exclude)"),$("#livemap_filter_cachename").val()&&(t.cachename=$("#livemap_filter_cachename").val()),"1;5"!=$("#livemap_filter_difficulty").slider("value")&&(t.difficulty=$("#livemap_filter_difficulty").slider("value")),"1;5"!=$("#livemap_filter_terrain").slider("value")&&(t.terrain=$("#livemap_filter_terrain").slider("value")),"0;10000"!=$("#livemap_filter_fp").slider("value")&&(t.fp=$("#livemap_filter_fp").slider("value")),"0;100"!=$("#livemap_filter_fpp").slider("value")&&(t.fpp=$("#livemap_filter_fpp").slider("value")),"0;100"!=$("#livemap_filter_fpw").slider("value")&&(t.fpw=$("#livemap_filter_fpw").slider("value")),"-10000;10000"!=$("#livemap_filter_elevation").slider("value")&&(t.elevation=$("#livemap_filter_elevation").slider("value")),0<$("#livemap_filter_geocacheSizes .overlay:not(.active)").length&&(i=[],$("#livemap_filter_geocacheSizes .overlay.active").each(function(e,a){i.push($(this).attr("data-geocacheSize"))}),t.geocacheSizes=i),t},ClearFilters:function(){PGC_LiveMap.Log("ClearFilters()"),$("#map_sidebar input:checked").each(function(e,a){$(this).prop("checked",!1)}),$("#livemap_filter_cacheTypes li img.exclude").each(function(e,a){$(this).removeClass("exclude")}),$("#livemap_filter_cachename").val(""),$("#livemap_filter_difficulty").slider("value",1,5),$("#livemap_filter_terrain").slider("value",1,5),$("#livemap_filter_fp").slider("value",0,1e4),$("#livemap_filter_fpp").slider("value",0,100),$("#livemap_filter_fpw").slider("value",0,100),$("#livemap_filter_elevation").slider("value",-1e4,1e4),$("#livemap_filter_geocacheSizes .overlay").addClass("active")},ParseSavedFilters:function(){PGC_LiveMap.Log("ParseSavedFilters()"),$.each(PGC_LiveMap.myData.savedFilters,function(e,r){var a,i,t;"roadtrip15_10FP"!=e&&"roadtrip15_event"!=e&&"roadtrip15_5"!=e&&"roadtrip15_cito"!=e&&"roadtrip15_mystery"!=e||$("#map_sidebar fieldset[data-groupname=roadtrip15] input[name="+e+"]").prop("checked",!0),"excludeFound"!=e&&"excludeOwned"!=e&&"excludePremium"!=e&&"excludeNotFound"!=e&&"excludeDisabled"!=e&&"excludeArchived"!=e||$("#map_sidebar fieldset[data-groupname=standardFilters] input[name="+e+"]").prop("checked",!0),"cacheTypes"==e&&$("#livemap_filter_cacheTypes li img").each(function(e,a){for(var i=$(a).attr("alt"),t=!0,o=0;oPGC_LiveMap.maxGetGeocachesWithinBoundingBoxThreads)&&(PGC_LiveMap.numGetGeocachesWithinBoundingBoxRunning++,PGC_LiveMap.GetGeocachesWithinBoundingBox(e,a),void delete PGC_LiveMap.getGeocachesWithinBoundingBoxQueue[e])}),!0},AddGeocacheTileToQueue:function(e,a){PGC_LiveMap.getGeocachesWithinBoundingBoxQueue[e]=a,PGC_LiveMap.loadingRectangles[e]||(a=[[a[1],a[0]],[a[3],a[2]]],PGC_LiveMap.loadingRectangles[e]=L.rectangle(a,{color:"#ff7800",weight:1,fillOpacity:.1,clickable:!1}),PGC_LiveMap.loadingRectangles[e].addTo(PGC_LiveMap.map))},SaveSettings:function(){PGC_LiveMap.Log("Saving settings");var e=$("#map_sidebar_settings_defaultTileLayer option:selected").val(),a=$("#map_sidebar_settings_saveFilters").prop("checked")?1:0,i=Number($("#livemap_settings_limit").slider("value")),a={defaultTileLayer:e,saveFilters:a,geocacheLimit:i};$("#map_sidebar_settings_submit").button("loading"),$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"SaveSettings",settings:a},success:function(e){PGC_LiveMap.saveMapFilter=!0,PGC_LiveMap.maxVisible=i,PGC_LiveMap.GetGeocaches(),PGC_LiveMap.Log("Saving settings success"),$("#map_sidebar_settings_submit").button("reset")},error:function(e){PGC_LiveMap.Log("Saving settings failed")}})},LiveMapButtonClick:function(){!0===PGC_LiveMap.liveMapEnabled?(PGC_LiveMap.liveMapEnabled=!1,$("#liveMapButton").html(HtmlEncode(PGC_LiveMap.params.strings.liveDisabled)),$("#liveMapButton").removeClass("enabled").addClass("disabled")):(PGC_LiveMap.liveMapEnabled=!0,$("#liveMapButton").html(HtmlEncode(PGC_LiveMap.params.strings.liveEnabled)),$("#liveMapButton").removeClass("disabled").addClass("enabled"),PGC_LiveMap.GetGeocaches())},Admin_GetElevationCluster:function(){for(var e=PGC_LiveMap.map.getBounds().getCenter(),a=[],i=(e.lat,e.lng,0),t=0,i=-10;i<=10;i++)for(t=-10;t<10;t++)a.push([e.lat+t*(500/111195/2),e.lng+i*(500/111195)]);$.ajax({url:"/ajax/livemap.php",dataType:"json",type:"POST",data:{cmd:"Admin_GetElevationCluster",coordinates:a},success:function(e){for(var a=0;a