<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
(function () {
    "use strict";
    mekkahExplorerApp.factory('mapService',
        [
            '$http', '$rootScope', 'helper', '$timeout', '$compile', function ($http, $rootScope, helper, $timeout, $compile) {
                
                $rootScope.loading = true;
                $rootScope.protocol = "https";
                //Esri setters in map.dir.js file
                var mapService = {
                    getURLFormated: function (url) {
                        if ($rootScope.config.needForceToHTTPS == true) {
                            if (url &amp;&amp; url.length &gt; 0) {
                                var arrUrl = url.split(':');
                                if (arrUrl[0].toLowerCase().indexOf('http') &gt;= 0) {
                                    url = url.replace(arrUrl[0] + ":", $rootScope.protocol + ":")
                                }
                            }
                            return url;
                        } else {
                            return url;
                        }
                     },
                    EsriTileLayer: null,
                    EsriBasemap: null,
                    EsriExpand: null,
                    EsriLocalBasemapsSource: null,
                    EsriBasemapGallery: null,
                    EsriLayerList:null,
                    EsriScaleBar:null,
                    EsriCoordinateConversion:null,
                    EsriGraphicsLayer:null,
                    EsriSketch:null,
                    EsriBookmarks: null,
                    EsriFeatureLayer: null,
                    view: null,
                    defaultBasemap: null,
                    basemapLegend: null,
                    rasterBasemapLayer: null,
                    getBasemaps: function () {
                        var basemaps = [];
                        for (var i = 0; i &lt; $rootScope.config.basemap.basemaps.length; i++) {
                            var basemap = $rootScope.config.basemap.basemaps[i];
                            if (basemap.needed == true) {
                                var baseLayers = [];
                                for (var j = 0; j &lt; basemap.baseLayers.length; j++) {
                                    var baseLayer = basemap.baseLayers[j];
                                    if (baseLayer.type == "TileLayer") {
                                        var _tileLayer = new mapService.EsriTileLayer({
                                            url: mapService.getURLFormated(baseLayer.url),
                                            customParameters: {
                                                infoNeeded: baseLayer.infoNeeded
                                            }
                                        });
                                        if (baseLayer.opacity)
                                            _tileLayer.opacity = baseLayer.opacity;

                                        baseLayers.push(_tileLayer);
                                    } else if (baseLayer.type == "MapImageLayer") {
                                        var _MapImageLayer = new mapService.EsriMapImageLayer({
                                            url: mapService.getURLFormated(baseLayer.url),
                                            legendEnabled: false,
                                            imageFormat: 'png32',
                                            dpi:96,
                                            customParameters: {
                                                infoNeeded: baseLayer.infoNeeded
                                            }
                                        });
                                        if (baseLayer.opacity)
                                            _MapImageLayer.opacity = baseLayer.opacity;
                                        if (baseLayer.effect == true) {
                                            _MapImageLayer.effect = [
                                                {
                                                    scale: 36978595,
                                                    value: "drop-shadow(3px, 3px, 4px)"
                                                },
                                                {
                                                    scale: 18489297,
                                                    value: "drop-shadow(2px, 2px, 3px)"
                                                },
                                                {
                                                    scale: 4622324,
                                                    value: "drop-shadow(1px, 1px, 2px)"
                                                }
                                            ];
                                        }

                                        baseLayers.push(_MapImageLayer);
                                    }
                                    else if (baseLayer.isRaster) {
                                        if ($rootScope.config.rasterBasemap.type == "TileLayer") {
                                            if (mapService.rasterBasemapLayer == null) {
                                                var _tileLayer = new mapService.EsriTileLayer({
                                                    url: mapService.getURLFormated($rootScope.config.rasterBasemap.url),
                                                    customParameters: {
                                                        isRaster: true
                                                    }
                                                });
                                                if (baseLayer.opacity)
                                                    _tileLayer.opacity = baseLayer.opacity;
                                               mapService.rasterBasemapLayer = _tileLayer;
                                            }
                                            baseLayers.push(mapService.rasterBasemapLayer);
                                        } else if ($rootScope.config.rasterBasemap.type == "MapImageLayer") {
                                            if (mapService.rasterBasemapLayer == null) {
                                                var _MapImageLayer = new mapService.EsriMapImageLayer({
                                                    url: mapService.getURLFormated($rootScope.config.rasterBasemap.url),
                                                    legendEnabled:false,
                                                    customParameters: {
                                                        isRaster: true
                                                    },
                                                    imageFormat: 'png32',
                                                });
                                                if (baseLayer.opacity)
                                                    _MapImageLayer.opacity = baseLayer.opacity;
                                                mapService.rasterBasemapLayer = _MapImageLayer;
                                            }
                                            baseLayers.push(mapService.rasterBasemapLayer);
                                        }

                                    }
                                }
                                if (basemap.thumbnailUrl.indexOf('http') &lt; 0) {
                                    basemap.thumbnailUrl = window.appPath + basemap.thumbnailUrl;
                                }
                                var _basemap = new mapService.EsriBasemap({
                                    baseLayers: baseLayers,
                                    thumbnailUrl: mapService.getURLFormated(basemap.thumbnailUrl),
                                    title: basemap.title,
                                    id: basemap.id
                                });
                                if (mapService.defaultBasemap == null &amp;&amp; basemap.isDefault == true) {
                                    mapService.defaultBasemap = _basemap
                                }
                                basemaps.push(_basemap);
                            }
                        }
                        if (mapService.defaultBasemap == null &amp;&amp; basemaps.length &gt; 0)
                            mapService.defaultBasemap = basemaps[0];

                        return basemaps;
                    },
                    enableBasemapList: function () {
                        if($rootScope.config.basemap.show == true){
                            var basemapGallery = new mapService.EsriBasemapGallery({
                                source: new mapService.EsriLocalBasemapsSource({
                                    basemaps: mapService.basemaps
                                }),
                                view: mapService.view
                            });
                            var basemapGalleryExpand = new mapService.EsriExpand({
                                view: mapService.view,
                                content: basemapGallery,
                                expanded: false
                            });
                            mapService.view.ui.add(basemapGalleryExpand, $rootScope.config.basemap.basemapLocation);
                            if (mapService.basemapLegend) {
                                var legend = new mapService.EsriLegend({
                                    view: mapService.view,
                                    layerInfos: [{
                                        title: "خريطة الأساس",
                                        layer: mapService.basemapLegend
                                    }]
                                });
                                var legendExpand = new mapService.EsriExpand({
                                    view: mapService.view,
                                    content: legend,
                                    expanded: false
                                });
                                mapService.view.ui.add(legendExpand, $rootScope.config.basemap.basemapLocation);
                            }


                        }
                    },
                    scaleBarAfterAdded: function (me, scope) {
                        var scaleBar = document.getElementsByClassName('esri-scale-bar');
                        if (scaleBar.length == 0) {
                            $timeout(function () {
                                me.scaleBarAfterAdded(me, scope);
                            }, 0, false);
                        } else {
                            var html = '&lt;div class="scale-bar-custom"&gt;1:{{mapService.view.scale.toFixed()}}&lt;/div&gt;'
                            var com = $compile(html)(scope);
                            scaleBar[0].parentElement.className = scaleBar[0].parentElement.className + " esri-ui-bottom-left-custom"
                            var element = angular.element(scaleBar[0].parentElement)
                            element.append(com);
                        }
                    },
                    enableScaleBar: function (scope){
                        if ($rootScope.config.scaleBar.show) {
                            var scaleBar = new mapService.EsriScaleBar({
                                view: mapService.view,
                                unit: $rootScope.config.scaleBar.unit
                            });
                            mapService.view.ui.add(scaleBar, {
                                position: $rootScope.config.scaleBar.location
                            });
                            this.scaleBarAfterAdded(this, scope);
                        }
                    },
                    enableMouseCoordinates: function () {
                        var isMobile = helper.mobileAndTabletCheck();
                        if ($rootScope.config.mouseCoordinates.show) {
                            var coordinateConversion = new mapService.EsriCoordinateConversion({
                                view: mapService.view
                            });
                            var coordinateConversionExpand = new mapService.EsriExpand({
                                expandIconClass: "fa fa-map-marker", 
                                view: mapService.view,
                                content: coordinateConversion,
                                expanded: !isMobile
                            });
                            mapService.view.ui.add(coordinateConversionExpand, $rootScope.config.mouseCoordinates.location);
                        }
                    }
                };
                helper.mapService = mapService;
                return mapService;
            }
        ]);

})();</pre></body></html>