{ "version": 3, "sources": ["../../node_modules/debounce/index.js", "../../src/js/map.js"], "sourcesContent": ["/**\n * Returns a function, that, as long as it continues to be invoked, will not\n * be triggered. The function will be called after it stops being called for\n * N milliseconds. If `immediate` is passed, trigger the function on the\n * leading edge, instead of the trailing. The function also has a property 'clear' \n * that is a function which will clear the timer to prevent previously scheduled executions. \n *\n * @source underscore.js\n * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/\n * @param {Function} function to wrap\n * @param {Number} timeout in ms (`100`)\n * @param {Boolean} whether to execute at the beginning (`false`)\n * @api public\n */\nfunction debounce(func, wait, immediate){\n var timeout, args, context, timestamp, result;\n if (null == wait) wait = 100;\n\n function later() {\n var last = Date.now() - timestamp;\n\n if (last < wait && last >= 0) {\n timeout = setTimeout(later, wait - last);\n } else {\n timeout = null;\n if (!immediate) {\n result = func.apply(context, args);\n context = args = null;\n }\n }\n };\n\n var debounced = function(){\n context = this;\n args = arguments;\n timestamp = Date.now();\n var callNow = immediate && !timeout;\n if (!timeout) timeout = setTimeout(later, wait);\n if (callNow) {\n result = func.apply(context, args);\n context = args = null;\n }\n\n return result;\n };\n\n debounced.clear = function() {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n };\n \n debounced.flush = function() {\n if (timeout) {\n result = func.apply(context, args);\n context = args = null;\n \n clearTimeout(timeout);\n timeout = null;\n }\n };\n\n return debounced;\n};\n\n// Adds compatibility for ES modules\ndebounce.debounce = debounce;\n\nmodule.exports = debounce;\n", "import debounce from 'debounce'\n\nconst mapEl = document.getElementById('map')\nif (mapEl) {\n\twindow.addEventListener('load', initMap)\n}\n\nfunction initMap() {\n\tconst centerPosition = {\n\t\tlat: _mapMarker.latitude,\n\t\tlng: _mapMarker.longitude,\n\t}\n\tvar bounds = new google.maps.LatLngBounds()\n\tbounds.extend(\n\t\tnew google.maps.LatLng(_mapMarker.latitude, _mapMarker.longitude)\n\t)\n\n\tlet zoomLevel\n\tif (window.innerWidth >= 1200) {\n\t\tzoomLevel = 15\n\t} else if (window.innerWidth >= 992) {\n\t\tzoomLevel = 14\n\t} else {\n\t\tzoomLevel = 13\n\t}\n\n\tconst map = new google.maps.Map(document.getElementById('map'), {\n\t\tcenter: centerPosition,\n\t\tzoom: zoomLevel,\n\t\tmapId: '7b182fcc799e33d8',\n\t\tdisableDefaultUI: true,\n\t})\n\n\t// map.setOptions({draggable: false, zoomControl: false, scrollwheel: false, disableDoubleClickZoom: true});\n\tmap.setOptions({ scrollwheel: false })\n\n\tconst image = {\n\t\turl: '/wp-content/themes/propaganda-theme/assets/svg/map-marker-gold.svg',\n\t\tsize: new google.maps.Size(52, 80),\n\t\torigin: new google.maps.Point(0, 0),\n\t\tanchor: new google.maps.Point(26, 80),\n\t}\n\n\tconst marker = new google.maps.Marker({\n\t\tposition: {\n\t\t\tlat: _mapMarker.latitude,\n\t\t\tlng: _mapMarker.longitude,\n\t\t},\n\t\tmap,\n\t\ticon: image,\n\t})\n\n\tconst refreshCenter = debounce(() => {\n\t\t// TODO: This is slightly annoying/unsightly when resizing the screen, clean it up if we have time\n\t\tmap.setCenter(centerPosition)\n\n\t\tif (window.innerWidth < 1200) {\n\t\t\treturn\n\t\t}\n\t\t// retrieve the lat lng for the far extremities of the (visible) map\n\t\tvar latLngBounds = map.getBounds()\n\t\tvar neBound = latLngBounds.getNorthEast()\n\t\tvar swBound = latLngBounds.getSouthWest()\n\n\t\t// convert the bounds in pixels\n\t\tvar neBoundInPx = map.getProjection().fromLatLngToPoint(neBound)\n\t\tvar swBoundInPx = map.getProjection().fromLatLngToPoint(swBound)\n\n\t\tvar offset\n\t\tif (window.innerWidth >= 992) {\n\t\t\toffset = (neBoundInPx.x - swBoundInPx.x) * 0.25\n\t\t}\n\n\t\tvar center = map.getCenter()\n\t\tvar centerPoint = map.getProjection().fromLatLngToPoint(center)\n\t\tcenterPoint.x -= offset\n\t\tmap.setCenter(map.getProjection().fromPointToLatLng(centerPoint))\n\t}, 100)\n\n\tmap.addListener('projection_changed', () => {\n\t\trefreshCenter()\n\t})\n\n\twindow.addEventListener('resize', () => {\n\t\trefreshCenter()\n\t})\n\n\tgoogle.maps.event.addListenerOnce(map, 'idle', () => {\n\t\trefreshCenter()\n\t})\n}\n"], "mappings": "4hBAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAcA,SAASC,EAASC,EAAMC,EAAMC,EAAU,CACtC,IAAIC,EAASC,EAAMC,EAASC,EAAWC,EAC3BN,GAAR,OAAcA,EAAO,KAEzB,SAASO,GAAQ,CACf,IAAIC,EAAO,KAAK,IAAI,EAAIH,EAEpBG,EAAOR,GAAQQ,GAAQ,EACzBN,EAAU,WAAWK,EAAOP,EAAOQ,CAAI,GAEvCN,EAAU,KACLD,IACHK,EAASP,EAAK,MAAMK,EAASD,CAAI,EACjCC,EAAUD,EAAO,MAGvB,CAEA,IAAIM,EAAY,UAAU,CACxBL,EAAU,KACVD,EAAO,UACPE,EAAY,KAAK,IAAI,EACrB,IAAIK,EAAUT,GAAa,CAACC,EAC5B,OAAKA,IAASA,EAAU,WAAWK,EAAOP,CAAI,GAC1CU,IACFJ,EAASP,EAAK,MAAMK,EAASD,CAAI,EACjCC,EAAUD,EAAO,MAGZG,CACT,EAEA,OAAAG,EAAU,MAAQ,UAAW,CACvBP,IACF,aAAaA,CAAO,EACpBA,EAAU,KAEd,EAEAO,EAAU,MAAQ,UAAW,CACvBP,IACFI,EAASP,EAAK,MAAMK,EAASD,CAAI,EACjCC,EAAUD,EAAO,KAEjB,aAAaD,CAAO,EACpBA,EAAU,KAEd,EAEOO,CACT,CAGAX,EAAS,SAAWA,EAEpBD,EAAO,QAAUC,ICrEjB,IAAAa,EAAqB,OAEfC,EAAQ,SAAS,eAAe,KAAK,EACvCA,GACH,OAAO,iBAAiB,OAAQC,CAAO,EAGxC,SAASA,GAAU,CAClB,IAAMC,EAAiB,CACtB,IAAK,WAAW,SAChB,IAAK,WAAW,SACjB,EACA,IAAIC,EAAS,IAAI,OAAO,KAAK,aAC7BA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iB,SAAU,IAAM,CACvCA,EAAc,CACf,CAAC,EAED,OAAO,KAAK,MAAM,gBAAgBH,EAAK,OAAQ,IAAM,CACpDG,EAAc,CACf,CAAC,CACF", "names": ["require_debounce", "__commonJSMin", "exports", "module", "debounce", "func", "wait", "immediate", "timeout", "args", "context", "timestamp", "result", "later", "last", "debounced", "callNow", "import_debounce", "mapEl", "initMap", "centerPosition", "bounds", "zoomLevel", "map", "image", "marker", "refreshCenter", "debounce", "latLngBounds", "neBound", "swBound", "neBoundInPx", "swBoundInPx", "offset", "center", "centerPoint"] }