{"version":3,"file":"point-of-sale-map-w8ifjFgB.js","sources":["../../../Scripts/components/point-of-sale-map.html?vue-htmltemplate","../../../Scripts/components/point-of-sale-map.ts"],"sourcesContent":["
\n","import { Vue, Component, Prop, Watch } from \"@wagich/vue-facing-decorator-metadata\";\n\nimport mapboxgl from \"mapbox-gl\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nmapboxgl.accessToken = \"pk.eyJ1Ijoid2FnbmVyZ3JhcGhpY3MiLCJhIjoiY2puMGRlc2Y5MTlmbzNrcW9sZzd0enJ4MCJ9.9UzDSDeYnTP2Qwzsi8Q9_g\";\n\nconst glacenheitMarkerData = \"data:image/svg+xml;base64,PHN2ZyBpZD0iRWJlbmVfMSIgZGF0YS1uYW1lPSJFYmVuZSAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTAuMTUgMTEwLjE1Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2M1MDA3Mjt9LmNscy0ye2ZpbGw6IzQ5MDIwMDt9LmNscy0ze2ZpbGw6I2ZiZjVlNzt9PC9zdHlsZT48L2RlZnM+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMjIuOTQsODUuMjFhNDQsNDQsMCwwLDAsNS40Niw0LjkyLDI1LjM2LDI1LjM2LDAsMCwwLDYuMzQtMy45NWM0LjE4LTMuNiwxMy4xNS0xNS42NywxMy4xNS0xNS42N0E0NSw0NSwwLDAsMCwzMSw3Ny43YTMyLjc4LDMyLjc4LDAsMCwwLTguMDYsNy41MU05OS4xNyw1NS4wOEE0NC4xLDQ0LjEsMCwxLDAsMjIuMTEsODQuMjljMS43OS0yLjQzLDQuOTMtNS4xMSw5LjE2LTcuNzdhNTAuMzcsNTAuMzcsMCwwLDEsMTcuMTctNi44NWw1LjE3LTcuNDdhMTUuMiwxNS4yLDAsMCwxLTUuMzMsMS4wN2MtNC42OCwwLTcuMzItMi41OC03LjMyLTYuOTFzMi4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4zLDAsMCwwLTMuNjMuMjhzLTIuOTEsMy44Ny0zLjc0LDQuODJhMTA5LjM0LDEwOS4zNCwwLDAsMS05LjUyLDEwLDM0LjgyLDM0LjgyLDAsMCwxLTksNi4xQTQ0LDQ0LDAsMCwwLDk5LjE3LDU1LjA4TTc3LjkzLDI3LjE3Yy02LjYsMC0xOC4zNyw3LTI1LjA5LDE0LjQ5YTE2Ljc3LDE2Ljc3LDAsMCwwLDcuNTQsMS40QTMyLjExLDMyLjExLDAsMCwwLDczLjIsNDAuNDJjNi4yMi0yLjU4LDEwLTYuMjksMTAtOS42NiwwLTIuMy0yLTMuNTktNS4yMy0zLjU5Ii8+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJNNTUuMDgsMTA0LjhBNDkuNzMsNDkuNzMsMCwxLDEsMTA0LjgsNTUuMDgsNDkuNzksNDkuNzksMCwwLDEsNTUuMDgsMTA0LjhtMC05OC4zNGE0OC42Miw0OC42MiwwLDEsMCw0OC42MSw0OC42MkE0OC42Nyw0OC42NywwLDAsMCw1NS4wOCw2LjQ2Ii8+PHBhdGggY2xhc3M9ImNscy0zIiBkPSJNNTUuMDgsMTEwLjE1YTU1LjA4LDU1LjA4LDAsMSwxLDU1LjA3LTU1LjA3LDU1LjE0LDU1LjE0LDAsMCwxLTU1LjA3LDU1LjA3bTAtMTA1LjcxYTUwLjY0LDUwLjY0LDAsMSwwLDUwLjYzLDUwLjY0QTUwLjcsNTAuNywwLDAsMCw1NS4wOCw0LjQ0Ii8+PC9zdmc+\";\n\nimport { render } from \"./point-of-sale-map.html\";\nimport \"./point-of-sale-map.scss\";\n\n\n@Component({\n\trender\n})\nexport class PointOfSaleMap extends Vue {\n\tprivate map: mapboxgl.Map;\n\tprivate featureCollection: GeoJSON.FeatureCollection;\n\tprivate markerImage: string;\n\n\t@Prop() datasourceId: string;\n\n\tcreated() {\n\t\tif (this.datasourceId != null) {\n\t\t\tlet dataElement = document.getElementById(this.datasourceId);\n\t\t\tif (dataElement != null) {\n\t\t\t\tthis.featureCollection = JSON.parse(dataElement.innerHTML);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync mounted() {\n\t\tvar featureBounds = new mapboxgl.LngLatBounds();\n\t\tthis.featureCollection.features.forEach(function (feature) {\n\t\t\tfeatureBounds.extend((feature.geometry as GeoJSON.Point).coordinates as [number, number]);\n\t\t});\n\n\t\tthis.map = new mapboxgl.Map({\n\t\t\tcontainer: (this.$refs as any).map,\n\t\t\tstyle: \"mapbox://styles/wagnergraphics/ckrxdia0p9mh917p45kkc3339\",\n\t\t\tbounds: featureBounds,\n\t\t\tfitBoundsOptions: {\n\t\t\t\tpadding: 50\n\t\t\t}\n\t\t});\n\t\tthis.map.addControl(new mapboxgl.NavigationControl());\n\n\t\tawait new Promise(resolve => {\n\t\t\tthis.map.on(\"load\", () => resolve());\n\t\t});\n\n\t\tawait new Promise(resolve => {\n\t\t\tvar markerImage = new Image(64, 64);\n\t\t\tmarkerImage.onload = () => {\n\t\t\t\tthis.map.addImage(\"glacenheit\", markerImage, { pixelRatio: 2 })\n\t\t\t\tresolve();\n\t\t\t}\n\t\t\tmarkerImage.src = glacenheitMarkerData;\n\t\t});\n\n\t\tthis.map.addSource(\"points-of-sale\", {\n\t\t\ttype: \"geojson\",\n\t\t\tdata: this.featureCollection\n\t\t});\n\n\t\tthis.map.addLayer({\n\t\t\tid: \"points-of-sale\",\n\t\t\ttype: \"symbol\",\n\t\t\tsource: \"points-of-sale\",\n\t\t\tlayout: {\n\t\t\t\t\"icon-allow-overlap\": true,\n\t\t\t\t\"icon-image\": [\"get\", \"productType\"],\n\t\t\t\t\"text-field\": [\"get\", \"shortName\"],\n\t\t\t\t\"text-font\": [\"Asap Regular\"],\n\t\t\t\t\"text-size\": 12,\n\t\t\t\t\"text-optional\": true,\n\t\t\t\t\"text-offset\": [0, 1.25],\n\t\t\t\t\"text-anchor\": 'top'\n\t\t\t}\n\t\t});\n\n\t\tthis.map.on(\"click\", \"points-of-sale\", e => {\n\t\t\tif (e.features == null) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar coordinates = (e.features[0].geometry as GeoJSON.Point).coordinates.slice() as [number, number];\n\n\t\t\t// Ensure that if the map is zoomed out such that multiple\n\t\t\t// copies of the feature are visible, the popup appears\n\t\t\t// over the copy being pointed to.\n\t\t\twhile (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {\n\t\t\t\tcoordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;\n\t\t\t}\n\n\t\t\tvar content = document.createElement(\"div\");\n\t\t\tcontent.classList.add(\"point-of-sale-map__popup\");\n\n\t\t\tvar text = document.createElement(\"div\");\n\t\t\ttext.classList.add(\"title\", \"is-6\", \"mb-0\");\n\t\t\ttext.append(e.features[0].properties!.name);\n\t\t\tcontent.append(text);\n\n\t\t\tvar website = e.features[0].properties!.website;\n\t\t\tif (website != null) {\n\t\t\t\tlet a = document.createElement(\"a\");\n\t\t\t\ta.href = website;\n\t\t\t\ta.rel = \"\";\n\t\t\t\ta.target = \"_blank\";\n\t\t\t\ta.append(new URL(website).hostname);\n\t\t\t\tcontent.append(a);\n\t\t\t}\n\n\t\t\tnew mapboxgl.Popup()\n\t\t\t\t.setLngLat(coordinates)\n\t\t\t\t.setDOMContent(content)\n\t\t\t\t.addTo(this.map);\n\t\t});\n\n\t\t// Change the cursor to a pointer when the mouse is over the places layer.\n\t\tthis.map.on(\"mouseenter\", \"points-of-sale\", () => {\n\t\t\tthis.map.getCanvas().style.cursor = \"pointer\";\n\t\t});\n\n\t\t// Change it back to a pointer when it leaves.\n\t\tthis.map.on(\"mouseleave\", \"points-of-sale\", () => {\n\t\t\tthis.map.getCanvas().style.cursor = \"\";\n\t\t});\n\t}\n}\n"],"names":["_openBlock","_createElementBlock","mapboxgl","accessToken","glacenheitMarkerData","PointOfSaleMap","Vue","created","datasourceId","dataElement","document","getElementById","featureCollection","JSON","parse","innerHTML","mounted","featureBounds","LngLatBounds","features","forEach","feature","extend","geometry","coordinates","map","Map","container","$refs","style","bounds","fitBoundsOptions","padding","addControl","NavigationControl","Promise","resolve","on","markerImage","Image","onload","addImage","pixelRatio","src","addSource","type","data","addLayer","id","source","layout","e","slice","Math","abs","lngLat","lng","content","createElement","classList","add","text","append","properties","name","website","a","href","rel","target","URL","hostname","Popup","setLngLat","setDOMContent","addTo","getCanvas","cursor","render"],"mappings":";;;;AAAK,EAAA,KAAK,EAAC,8BAA8B;AAAC,EAAA,GAAG,EAAC;;;;AAA9C,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,CAA0D,OAA1D,UAA0D,EAAA,IAAA,EAAA,GAAA,CAAA;;;ACI1DC,QAAAA,CAASC,WAAW,GAAG,oGAAA;AAEvB,MAAMC,oBAAuB,GAAA,gjFAAA;AAStB,MAAMC,cAAuBC,SAAAA,GAAAA,CAAAA;IAOnCC,OAAU,GAAA;AACT,QAAA,IAAI,IAAI,CAACC,YAAY,IAAI,IAAM,EAAA;AAC9B,YAAA,IAAIC,cAAcC,QAASC,CAAAA,cAAc,CAAC,IAAI,CAACH,YAAY,CAAA;AAC3D,YAAA,IAAIC,eAAe,IAAM,EAAA;AACxB,gBAAA,IAAI,CAACG,iBAAiB,GAAGC,KAAKC,KAAK,CAACL,YAAYM,SAAS,CAAA;AAC1D;AACD;AACD;AAEA,IAAA,MAAMC,OAAU,GAAA;QACf,IAAIC,aAAAA,GAAgB,IAAIf,QAAAA,CAASgB,YAAY,EAAA;QAC7C,IAAI,CAACN,iBAAiB,CAACO,QAAQ,CAACC,OAAO,CAAC,SAAUC,OAAO,EAAA;AACxDJ,YAAAA,aAAAA,CAAcK,MAAM,CAAED,OAAQE,CAAAA,QAAQ,CAAmBC,WAAW,CAAA;AACrE,SAAA,CAAA;AAEA,QAAA,IAAI,CAACC,GAAG,GAAG,IAAIvB,QAAAA,CAASwB,GAAG,CAAC;AAC3BC,YAAAA,SAAAA,EAAW,IAAK,CAACC,KAAK,CAASH,GAAG;YAClCI,KAAO,EAAA,0DAAA;YACPC,MA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