{"version":3,"file":"index-C-BMOoEA.js","sources":["../../../app/assets/javascripts/concepts/listings/pictures_and_map_browser/with_toggle/static_map/index.ts","../../../app/assets/javascripts/concepts/listings/pictures_and_map_browser/with_toggle/index.ts"],"sourcesContent":["\nimport $ from \"jquery\"\nimport _once from \"lodash/once\"\nimport L from \"plugins/leaflet\"\nimport Promise from \"plugins/bluebird\"\n\nimport AssetsInfoStore from \"app/assets_info_store\"\n\nimport DomIdGenerator from \"app/utils/dom_id_generator\"\n\nimport LeafletMapTileLayer from \"app/map/leaflet/map_tile_layer\"\nimport LeafletSettings from \"app/map/leaflet/settings\"\n\nimport SwitchMode from \"components/widgets/switch_mode\"\n\n\ninterface InputSelector {\n main?: string | JQuery,\n switch?: string,\n map_container?: string,\n}\n\ninterface Selector {\n main: string | JQuery,\n switch: string,\n map_container: string,\n}\n\nconst default_selector: Selector = {\n main: \".cell--listings--pictures-and-map-browser--with-toggle\",\n switch: \".cell--listings--pictures-and-map-browser--with-toggle__switch--map\",\n map_container: \".cell--listings--pictures-and-map-browser--with-toggle__static-map-box\",\n}\n\n\nconst init = (selector?: InputSelector) => {\n const sele: Selector = Object.assign({}, default_selector, selector)\n\n const $el = $(sele.main)\n const $map_container = $el.find(sele.map_container)\n\n const render_map = _once(() => {\n const map_el = $map_container[0]\n\n const dom_id = DomIdGenerator.generateNewId()\n // Set new ID if applicable\n if (dom_id !== map_el.id) { map_el.setAttribute(\"id\", dom_id) }\n\n const lat = parseFloat($map_container.data(\"lat\"))\n const lng = parseFloat($map_container.data(\"lng\"))\n const center = L.latLng(lat, lng)\n\n // Generate ID for Leaflet map, if absent\n const map_canvas_dom_id = dom_id\n\n // If we add map tile layer AFTER creating map object\n // The location of tile layer is drifted on load\n // To workaround this we create tile layer first and\n // pass it on map object creation\n Promise.all([\n LeafletMapTileLayer.getNewTileLayerPromise(),\n AssetsInfoStore.fetch(\"map/markers/s-spacious.png\"),\n ])\n .spread((map_tile_layer, icon_image_data) => {\n const leaflet_map =\n LeafletSettings.get_use_baidu_maps() ?\n L.map(map_canvas_dom_id, {\n center: center,\n\n zoom: 17,\n minZoom: 17,\n maxZoom: 17,\n\n // Interaction Options\n dragging: false,\n touchZoom: false,\n scrollWheelZoom: false,\n doubleClickZoom: false,\n boxZoom: false,\n tap: false,\n\n // Control options\n zoomControl: false,\n attributionControl: false,\n\n layers: [\n map_tile_layer,\n ],\n })\n :\n L.map(map_canvas_dom_id, {\n center: center,\n\n zoom: 17,\n minZoom: 17,\n maxZoom: 17,\n\n // Interaction Options\n dragging: false,\n touchZoom: false,\n scrollWheelZoom: false,\n doubleClickZoom: false,\n boxZoom: false,\n tap: false,\n\n // Control options\n zoomControl: false,\n attributionControl: false,\n\n layers: [\n map_tile_layer,\n ],\n })\n\n const marker_icon = L.icon({\n iconUrl: icon_image_data.url,\n iconSize: [25, 29],\n })\n L.marker(center, {\n icon: marker_icon,\n }).addTo(leaflet_map)\n\n SwitchMode.on(\"switch_mode:mode_switched\", () => {\n if (! $map_container.is(\":visible\")) { return }\n\n leaflet_map.invalidateSize()\n leaflet_map.panTo(center, {\n animate: false,\n })\n })\n })\n .done()\n })\n\n // If already visible\n // Render map immediately\n // Otherwise only render on button click\n if ($map_container.is(\":visible\") && document.getElementById(\"map-canvas\")) {\n render_map()\n }\n else {\n $el.find(sele.switch)\n .on(\"click\", render_map)\n }\n}\n\n\nexport default {\n init: init,\n}\n","\n// region JS Imports\n\n// region External Modules\nimport $ from \"jquery\"\nimport u from \"umbrellajs\"\n// endregion External Modules\n\n// Private Modules\n// Private Modules\n\n// region Public Components\n// endregion Public Components\n\n// region Private Components\nimport GoogleStreetView from \"./google_street_view\"\nimport StaticMap from \"./static_map\"\n// endregion Private Components\n\n// endregion JS Imports\n\n\nconst CELL_CLASS_NAME = \"cell--listings--pictures-and-map-browser--with-toggle\"\nconst CELL_INITIALIZED_CLASS_NAME = `${CELL_CLASS_NAME}--js-spacious-initialized`\n\nconst init = () => {\n u(`.${CELL_CLASS_NAME}`).each((el) => {\n const $el = $(el)\n\n if (el.classList.contains(CELL_INITIALIZED_CLASS_NAME)) { return }\n el.classList.add(CELL_INITIALIZED_CLASS_NAME)\n\n StaticMap.init({\n main: $el,\n })\n\n GoogleStreetView.init({\n main: $el,\n })\n })\n}\n\n\nexport default {\n init,\n GoogleStreetView,\n}\n"],"names":["default_selector","init","selector","sele","$el","$","$map_container","render_map","_once","map_el","dom_id","DomIdGenerator","lat","lng","center","L","map_canvas_dom_id","Promise","LeafletMapTileLayer","AssetsInfoStore","map_tile_layer","icon_image_data","leaflet_map","LeafletSettings","marker_icon","SwitchMode","StaticMap","CELL_CLASS_NAME","CELL_INITIALIZED_CLASS_NAME","u","el","GoogleStreetView","WithToggle"],"mappings":"4dA4BA,MAAMA,EAA6B,CACjC,KAAgB,yDAChB,OAAgB,sEAChB,cAAgB,wEAClB,EAGMC,EAAQC,GAA6B,CACzC,MAAMC,EAAiB,OAAO,OAAO,CAAA,EAAIH,EAAkBE,CAAQ,EAE7DE,EAAMC,EAAEF,EAAK,IAAI,EACjBG,EAAiBF,EAAI,KAAKD,EAAK,aAAa,EAE5CI,EAAaC,EAAM,IAAM,CACvB,MAAAC,EAASH,EAAe,CAAC,EAEzBI,EAASC,EAAe,cAAc,EAExCD,IAAWD,EAAO,IAAaA,EAAA,aAAa,KAAMC,CAAM,EAE5D,MAAME,EAAM,WAAWN,EAAe,KAAK,KAAK,CAAC,EAC3CO,EAAM,WAAWP,EAAe,KAAK,KAAK,CAAC,EAC3CQ,EAASC,EAAE,OAAOH,EAAKC,CAAG,EAG1BG,EAAoBN,EAM1BO,EAAQ,IAAI,CACVC,EAAoB,uBAAuB,EAC3CC,EAAgB,MAAM,4BAA4B,CACnD,CAAA,EACA,OAAO,CAACC,EAAgBC,IAAoB,CAC3C,MAAMC,EACJC,EAAgB,mBACd,EAAAR,EAAE,IAAIC,EAAmB,CACvB,OAAAF,EAEA,KAAS,GACT,QAAS,GACT,QAAS,GAGT,SAAkB,GAClB,UAAkB,GAClB,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