Current File : /home/pacjaorg/www/cop/media/plg_system_nrframework/js/widgets/openstreetmap.js
function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}var NR_OSM_Map=function(){function t(t){if(t){this.ref=t,this.map_component=null,this.map=null,this.map_element=null,this.tooltip_overlay=null,this.map_object_settings={},this.options={};var e=36.891319,o=27.28348;if(this.defaults={lat:e,long:o,zoom:5,view:"road",scale:"metric",coordinates:[o,e],showMarker:!0,showMarkerTooltip:!1,markerImage:"media/plg_system_nrframework/img/marker.png",showAddressInput:!1,allowMarkerDrag:!1,allowMapClick:!1},this.ref instanceof HTMLElement)this.initWithDataAttributes();else{if(!(this.ref instanceof Object))return;this.initWithOptions(this.ref)}this.initSharedVariables(),this.setDefaultMapSettings()}}var e=t.prototype;return e.initWithDataAttributes=function(){this.map_component=this.ref,this.map_element=this.map_component.querySelector(".osm_map_item");var t={};t=_extends({},t,{},JSON.parse(this.map_element.dataset.options)),this.initWithOptions(t)},e.initWithOptions=function(t){void 0===t&&(t={});var e=t.value.split(",");t.lat=parseFloat(e[0])||this.defaults.lat,t.long=parseFloat(e[1])||this.defaults.long,t.coordinates=[t.long,t.lat],this.options=_extends({},this.defaults,{},t),this.map_component||(this.map_component=document.querySelector("#"+this.options.id).parentElement),this.map_element||(this.map_element=this.map_component.querySelector(".osm_map_item"))},e.initSharedVariables=function(){this.resetButton=this.map_component.querySelector(".map_reset_btn"),this.coords_input=this.map_component.querySelector(".nr_address_coords")},e.setDefaultMapSettings=function(){this.map_object_settings={layers:[new ol.layer.Tile({source:this.getMapView()})],target:this.map_element,view:new ol.View({center:ol.proj.transform(this.getCoordinates(),"EPSG:4326","EPSG:3857"),zoom:parseInt(this.options.zoom)})}},e.getMapView=function(){var t=new ol.source.XYZ({url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",maxZoom:19}),e=new ol.source.OSM;return"aerial"===this.options.view?t:e},e.render=function(){this.addScale(),this.renderMap(),this.addMarker(),this.addGeocoder(),this.options.readonly||this.options.disabled||(this.makeMarkerDraggable(),this.handleClearButton(),this.onMapClickUpdateMarker()),this.map_component.OpenStreetMap=this},e.renderMap=function(){this.map=new ol.Map(this.map_object_settings)},e.addScale=function(){if(!this.options.scale||"0"==this.options.scale)return!1;var t=[],e=this.getScaleControl();t.push(e),this.map_object_settings.controls=ol.control.defaults({attribution:!0}).extend(t)},e.addMarkerTooltip=function(){if(this.options.showMarkerTooltip){var n=this.map_component.querySelector(".marker-tooltip");n&&(this.tooltip_overlay&&this.map.removeOverlay(this.tooltip_overlay),this.tooltip_overlay=new ol.Overlay({element:n,positioning:"bottom-center",stopEvent:!0}),this.map.addOverlay(this.tooltip_overlay),this.map.addEventListener("click",function(t){var e=this.map.forEachFeatureAtPixel(t.pixel,function(t,e){return t});if(e){var o=e.getGeometry().getCoordinates();n.style.display="block",this.tooltip_overlay.setOffset([0,-35]),this.tooltip_overlay.setPosition(o)}else n.style.display="none"}.bind(this)))}},e.getScaleControl=function(){return new ol.control.ScaleLine({units:this.options.scale})},e.handleClearButton=function(){if(this.resetButton){var e=this.map_component.querySelector(".map-coordinates-setting");e&&this.resetButton.addEventListener("click",function(t){this.coords_input.value="",e.classList.add("is-hidden"),t.preventDefault()}.bind(this))}},e.handleGeocoderAddressUpdate=function(){this.map_component.querySelector(".ol-geocoder").addEventListener("click",function(t){var e=t.target,o="";"a"===e.tagName.toLowerCase()?o=e.querySelector("span").innerHTML:e.closest("a")&&(o=e.innerHTML),o&&(this.map_component.querySelector(".gcd-txt-input").value=o)}.bind(this))},e.addGeocoder=function(){this.options.showAddressInput&&(this.geocoder=new Geocoder("nominatim",{provider:"osm",lang:Joomla.getOptions("nrf_osm_settings").lang_tag,autoComplete:!0,autoCompleteMinLength:3,placeholder:Joomla.JText._("NR_OSM_ADDRESS_DESC"),targetType:"text-input",limit:5,keepOpen:!0,featureStyle:new ol.style.Style({zIndex:-100}),preventDefault:!0}),this.map.addControl(this.geocoder),this.options.readonly||this.options.disabled||(this.handleGeocoderEvent(),this.handleGeocoderAddressUpdate()))},e.handleGeocoderEvent=function(){var o=this;this.geocoder.on("addresschosen",function(t){var e=t.coordinate;o.updateCoordinates(e),o.setCenter(),o.map.getView().animate({zoom:o.map.getView().getZoom(),center:e})})},e.addMarker=function(){if(this.options.showMarker){var t=new ol.Feature({geometry:new ol.geom.Point(ol.proj.fromLonLat([this.options.long,this.options.lat]))});t.setStyle(new ol.style.Style({image:new ol.style.Icon({src:this.options.markerImage})}));var e=new ol.layer.Vector({source:new ol.source.Vector({features:[t]})});this.marker={feature:t,vector:e},this.map.addLayer(this.marker.vector),this.addMarkerTooltip()}},e.makeMarkerDraggable=function(){if(this.options.allowMarkerDrag){var e=this,t=new ol.interaction.Translate({features:new ol.Collection([this.marker.feature])});this.map.addInteraction(t),t.on("translateend",function(t){e.updateCoordinates(t.coordinate),e.addMarkerTooltip()})}},e.onMapClickUpdateMarker=function(){this.options.allowMapClick&&this.map.on("click",function(t){this.updateCoordinates(t.coordinate),this.setCenter()}.bind(this))},e.setCoordinates=function(t){this.options.coordinates=ol.proj.transform(t,"EPSG:3857","EPSG:4326")},e.updateCoordinates=function(t){this.setCoordinates(t),this.updateCoordinatesInput()},e.updateCoordinatesInput=function(){var t=this.getCoordinates();this.coords_input&&(t=[t[1],t[0]],this.coords_input.value=t.toString());var e=this.map_component.querySelector(".map-coordinates-setting:not(.coordinates_hidden)");e&&e.classList.remove("is-hidden")},e.setCenter=function(){var t=this.getCoordinates();this.marker.feature.setGeometry(new ol.geom.Point(ol.proj.fromLonLat(t)))},e.getCoordinates=function(){return this.options.coordinates},t}(),NR_OSM_Maps=function(){function t(){this.init()}return t.prototype.init=function(){if(window.IntersectionObserver){var t=document.querySelectorAll(".nr-lazyload-item.osm");if(t){var e=new IntersectionObserver(function(t,o){t.forEach(function(t){if(t.isIntersecting){var e=t.target.children[0].hasAttribute("data-options")?JSON.parse(t.target.children[0].dataset.options):t.target;new NR_OSM_Map(e).render(),o.unobserve(t.target)}})},{rootMargin:"0px 0px 0px 0px"});t.forEach(function(t){e.observe(t)})}}},t}();document.addEventListener("DOMContentLoaded",function(){new NR_OSM_Maps});

Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!