{"version":3,"sources":["../../source/js/main.js"],"names":["$","jQuery","window","LeapMap","mapId","options","extend","maxZoom","LeapMapPins","minZoom","styles","locations","lat","lng","zoom","markers","positions","center","clearAllMarkers","this","forEach","marker","setMap","addMarkers","_this","term","arguments","length","undefined","filter","location","term_id","timeout","addMarkerWithTimeout","_this2","pinLatLng","google","maps","LatLng","pin_location","push","setTimeout","icon","url","size","Size","width","height","scaledSize","origin","Point","anchor","colour","path","SymbolPath","CIRCLE","fillColor","fillOpacity","strokeColor","scale","infoWindow","InfoWindow","content","content_string","addListener","centerMap","bind","addMarker","latLng","_this3","Marker","title","display_name","ID","position","map","animation","Animation","DROP","event","closeInfoWindows","open","openInfoWindow","post","_this4","close","console","log","setCenter","setZoom","bounds","LatLngBounds","fitBounds","saveCenter","getCenter","doMap","mapCanvas","get","Map","mapTypeControl","streetViewControl","addDomListener","document","ready","$mapCanvas","LeapMaps","each","i","$map","data","script","createElement","onload","src","google_maps_api_key","getElementsByTagName","appendChild","UIkit","util","on","e","target","closest","prev","leapMap","find","click","preventDefault","removeClass","addClass","next"],"mappings":"0FAAA,IAACA,EAAAA,EA+MEC,OA7MFC,OAAOC,QAAU,SAAUC,EAAOC,GAYjC,OAVAA,EAAUL,EAAEM,OAAO,CAClBC,aAAwC,IAAxBC,YAAYD,QAA0B,KAAOC,YAAYD,QACzEE,aAAwC,IAAxBD,YAAYC,QAA0B,KAAOD,YAAYC,QACzEC,YAAsC,IAAvBF,YAAYE,OAAyB,GAAKF,YAAYE,OACrEC,UAAW,GACXC,IAAK,KACLC,IAAK,KACLC,KAAM,IACJT,GAEKL,EAAEM,OAAO,CAChBF,MAAAA,EACAW,QAAS,GACTC,UAAW,GACXC,OAAQ,KACRC,gBALgB,WAMfC,KAAKJ,QAAQK,QAAQ,SAAAC,GACpBA,EAAOC,OAAO,QAEfH,KAAKH,UAAY,GACjBG,KAAKJ,QAAU,IAEhBQ,WAZgB,WAYQ,IAAAC,EAAAL,KAAbM,EAAaC,UAAAC,O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,IACInB,EAAO5G,EAAEwH,EAAEC,QAAQC,QAAQ,sBAC3B5F,EAAW9B,EAAEmB,MAAM0F,KAAK,YACdJ,SAAS5E,OAAO,SAAA8C,GAAG,OAAIA,EAAIvE,OAASwG,EAAKC,KAAK,iBAAgB,GACpE3B,eAAepD,KAExB9B,EAAE,wBAAwB8H,MAAM,SAAAN,GAC/BA,EAAEO,iBACF/H,EAAEwH,EAAEC,QAAQC,QAAQ,SAASM,YAAY,UAE1ChI,EAAE,uBAAuB8H,MAAM,SAAAN,GAC9BA,EAAEO,iBACF/H,EAAEwH,EAAEC,QAAQC,QAAQ,SAASO,SAAS,UAEvCjI,EAAE,wBAAwB8H,MAAM,SAAAN,GAC/BA,EAAEO,iBACF,IACInB,EAAO5G,EAAEwH,EAAEC,QAAQS,KAAK,sBACxBN,EAAUnB,SAAS5E,OAAO,SAAA8C,GAAG,OAAIA,EAAIvE,OAASwG,EAAKC,KAAK,iBAAgB,GAC5Ee,EAAQ1G,kBACR0G,EAAQrG,aACRqG,EAAQ3D","sourcesContent":["($ => {\n\n\twindow.LeapMap = function (mapId, options) {\n\n\t\toptions = $.extend({\n\t\t\tmaxZoom: typeof LeapMapPins.maxZoom === 'undefined' ? null : LeapMapPins.maxZoom,\n\t\t\tminZoom: typeof LeapMapPins.minZoom === 'undefined' ? null : LeapMapPins.minZoom,\n\t\t\tstyles: typeof LeapMapPins.styles === 'undefined' ? [] : LeapMapPins.styles,\n\t\t\tlocations: [],\n\t\t\tlat: null,\n\t\t\tlng: null,\n\t\t\tzoom: 15\n\t\t}, options);\n\n\t\treturn $.extend({\n\t\t\tmapId,\n\t\t\tmarkers: [],\n\t\t\tpositions: [],\n\t\t\tcenter: null,\n\t\t\tclearAllMarkers() {\n\t\t\t\tthis.markers.forEach(marker => {\n\t\t\t\t\tmarker.setMap(null);\n\t\t\t\t});\n\t\t\t\tthis.positions = [];\n\t\t\t\tthis.markers = [];\n\t\t\t},\n\t\t\taddMarkers(term = null) {\n\t\t\t\tif (this.locations.length) {\n\t\t\t\t\tlet locations = this.locations;\n\t\t\t\t\tif (term) {\n\t\t\t\t\t\tlocations = locations.filter((location) => {\n\t\t\t\t\t\t\treturn location.term_id == term;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tlet timeout = 0;\n\t\t\t\t\tlocations.forEach((location) => {\n\t\t\t\t\t\tthis.addMarkerWithTimeout(location, timeout);\n\t\t\t\t\t\ttimeout += 5;\n\t\t\t\t\t});\n\t\t\t}\n\t\t\t},\n\t\t\taddMarkerWithTimeout(location, timeout) {\n\t\t\t\tlet pinLatLng = new google.maps.LatLng(location.pin_location);\n\t\t\t\tthis.positions.push(pinLatLng);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tlet icon = null;\n\t\t\t\t\tif (typeof location.styles !== 'undefined') {\n\t\t\t\t\t\tif (location.styles.icon) {\n\t\t\t\t\t\t\ticon = {\n\t\t\t\t\t\t\t\turl: location.styles.icon,\n\t\t\t\t\t\t\t\tsize: new google.maps.Size(location.styles.width, location.styles.height),\n\t\t\t\t\t\t\t\tscaledSize: new google.maps.Size(24, location.styles.height / location.styles.width * 24),\n\t\t\t\t\t\t\t\torigin: new google.maps.Point(0, 0),\n\t\t\t\t\t\t\t\tanchor: new google.maps.Point(12, 12),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (location.styles.colour) {\n\t\t\t\t\t\t\ticon = {\n\t\t\t\t\t\t\t\tpath: google.maps.SymbolPath.CIRCLE,\n\t\t\t\t\t\t\t\tfillColor: location.styles.colour,\n\t\t\t\t\t\t\t\tfillOpacity: .9,\n\t\t\t\t\t\t\t\tstrokeColor: location.styles.colour,\n\t\t\t\t\t\t\t\tscale: 7,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlet infoWindow = new google.maps.InfoWindow({\n\t\t\t\t\t\tcontent: location.content_string\n\t\t\t\t\t});\n\t\t\t\t\tinfoWindow.addListener('closeclick', this.centerMap.bind(this));\n\t\t\t\t\tlet marker = this.addMarker(location, pinLatLng, icon, infoWindow);\n\t\t\t\t\tthis.markers.push(marker);\n\t\t\t\t}, timeout);\n\t\t\t},\n\t\t\taddMarker(location, latLng, icon, infoWindow) {\n\t\t\t\tlet marker = new google.maps.Marker({\n\t\t\t\t\ttitle: location.display_name,\n\t\t\t\t\tID: location.ID,\n\t\t\t\t\tposition: latLng,\n\t\t\t\t\tmap: this.map,\n\t\t\t\t\ticon: icon,\n\t\t\t\t\tanimation: google.maps.Animation.DROP,\n\t\t\t\t});\n\t\t\t\tmarker.infoWindow = infoWindow;\n\t\t\t\tgoogle.maps.event.addListener(marker, 'click', (marker => {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tthis.closeInfoWindows();\n\t\t\t\t\t\tinfoWindow.open(this.map, marker);\n\t\t\t\t\t}\n\t\t\t\t})(marker));\n\t\t\t\treturn marker;\n\t\t\t},\n\t\t\topenInfoWindow(post) {\n\t\t\t\tthis.markers.forEach(marker => {\n\t\t\t\t\tmarker.infoWindow.close();\n\t\t\t\t\tif (marker.ID == post) {\n\t\t\t\t\t\tmarker.infoWindow.open(this.map, marker);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tcloseInfoWindows() {\n\t\t\t\tthis.markers.forEach(marker => {\n\t\t\t\t\tmarker.infoWindow.close();\n\t\t\t\t});\n\t\t\t},\n\t\t\tcenterMap() {\n\t\t\t\tconsole.log(this.lng)\n\t\t\t\tif (this.lat && this.lng) {\n\t\t\t\t\tthis.map.setCenter(this.center);\n\t\t\t\t\tif (this.zoom) {\n\t\t\t\t\t\tthis.map.setZoom(this.zoom);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet bounds = new google.maps.LatLngBounds();\n\t\t\t\t\tthis.positions.forEach(position => {\n\t\t\t\t\t\tbounds.extend(position);\n\t\t\t\t\t});\n\t\t\t\t\tthis.map.fitBounds(bounds);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsaveCenter() {\n\t\t\t\tthis.center = this.map.getCenter();\n\t\t\t},\n\t\t\tdoMap() {\n\t\t\t\tconst mapCanvas = $('[data-map=\"' + mapId + '\"]').get(0);\n\t\t\t\tif (typeof mapCanvas === 'undefined') {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.map = new google.maps.Map(mapCanvas, {\n\t\t\t\t\tzoom: this.zoom,\n\t\t\t\t\tcenter: new google.maps.LatLng(this.lat, this.lng),\n\t\t\t\t\tstyles: this.styles,\n\t\t\t\t\tmapTypeControl: false,\n\t\t\t\t\tstreetViewControl: false,\n\t\t\t\t\tmaxZoom: this.maxZoom,\n\t\t\t\t\tminZoom: this.minZoom\n\t\t\t\t});\n\t\t\t\tthis.saveCenter();\n\t\t\t\tthis.clearAllMarkers();\n\t\t\t\tthis.addMarkers();\n\t\t\t\tthis.centerMap();\n\t\t\t\tgoogle.maps.event.addDomListener(window, 'resize', this.centerMap.bind(this));\n\t\t\t}\n\t\t}, options)\n\t};\n\n\tfunction initmaps() {\n\n\t\tlet $mapCanvas = $('[data-map]');\n\n\t\tif (!$mapCanvas.length)\n\t\t\treturn;\n\n\t\twindow.LeapMaps = [];\n\n\t\t$mapCanvas.each((i, map) => {\n\t\t\tlet $map = $(map);\n\t\t\tLeapMaps.push(new LeapMap($map.data('map'), $map.data('options')));\n\t\t});\n\t\tif (window.google && window.google.maps) {\n\t\t\tLeapMaps.forEach(map => map.doMap());\n\t\t} else {\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.onload = () => {\n\t\t\t\tLeapMaps.forEach(map => map.doMap())\n\t\t\t}\n\t\t\tscript.src = \"https://maps.googleapis.com/maps/api/js?key=\" + LeapMapPins.google_maps_api_key;\n\t\t\tdocument.getElementsByTagName('head')[0].appendChild(script);\n\t\t}\n\n\t\tif (window.UIkit) {\n\t\t\tUIkit.util.on('.map_categories_menu', 'show', (e) => {\n\t\t\t\tlet\n\t\t\t\t\t\t\t\t$map = $(e.target).closest('[data-map-control]'),\n\t\t\t\t\t\t\t\tterm = $(e.target).prev('a').data('term'),\n\t\t\t\t\t\t\t\tleapMap = LeapMaps.filter(map => map.mapId == $map.data('map-control'))[0];\n\t\t\t\tleapMap.clearAllMarkers();\n\t\t\t\tleapMap.addMarkers(term);\n\t\t\t\tleapMap.centerMap();\n\t\t\t});\n\t\t\t$('.map_categories_menu').find('[data-location]').click(function (e) {\n\t\t\t\te.preventDefault();\n\t\t\t\tlet\n\t\t\t\t\t\t\t\t$map = $(e.target).closest('[data-map-control]'),\n\t\t\t\t\t\t\t\tlocation = $(this).data('location'),\n\t\t\t\t\t\t\t\tleapMap = LeapMaps.filter(map => map.mapId == $map.data('map-control'))[0];\n\t\t\t\tleapMap.openInfoWindow(location);\n\t\t\t});\n\t\t\t$('[data-click=\"close\"]').click(e => {\n\t\t\t\te.preventDefault();\n\t\t\t\t$(e.target).closest('aside').removeClass('open');\n\t\t\t});\n\t\t\t$('[data-click=\"open\"]').click(e => {\n\t\t\t\te.preventDefault();\n\t\t\t\t$(e.target).closest('aside').addClass('open');\n\t\t\t});\n\t\t\t$('[data-click=\"reset\"]').click(e => {\n\t\t\t\te.preventDefault();\n\t\t\t\tlet\n\t\t\t\t\t\t\t\t$map = $(e.target).next('[data-map-control]'),\n\t\t\t\t\t\t\t\tleapMap = LeapMaps.filter(map => map.mapId == $map.data('map-control'))[0];\n\t\t\t\tleapMap.clearAllMarkers();\n\t\t\t\tleapMap.addMarkers();\n\t\t\t\tleapMap.centerMap();\n\t\t\t});\n\t\t}\n\t}\n\t$(document).ready(initmaps);\n})(jQuery)"]}