1'use strict'; 2 3 4 5(function(angular) { 6 angular.module('BruSo.visitor').controller('MapCustomController', 7 [ '$scope', '$controller', '$timeout','$http','$location', '$translate', 'Maps', 'COMMON', 'Search', 'MyFolders', 'User', 'Spinner', 'Organisations', 8 function($scope, $controller, $timeout, $http, $location, $translate, Maps, COMMON, Search, MyFolders, User, Spinner, Organisations, ) { 9 10 angular.extend(this, $controller('MapController', {$scope: $scope})); 11 12 $scope.mapId = COMMON.ORGANISATIONS.MAP_CUSTOM.ID; 13 $scope.showList = false; 14 $scope.customMap = true; 15 $scope.customSearches = Maps.customSearches; 16 $scope.searchName = {value:''}; 17 18 $scope.mergeLayerControl = {}; 19 20 if(!$scope.changeRequest){ 21 $scope.changeRequest = {}; 22 } 23 if(!$scope.changeRequestBackup){ 24 $scope.changeRequestBackup = {}; 25 } 26 27 $scope.initMapCustom = function(){ 28 Maps.customSearches.length = 0; 29 $timeout(function(){ 30 Maps.initCustomMap($scope.mapId, $scope.lang()); 31 $scope.mergeLayerControl = { 32 visible: true, 33 clustered: false, 34 colorCode: Maps.randomColors[Maps.randomColorsCount], 35 popOverText:'organisations.showClusters', 36 mapIndex:Maps.mergeLayerIndex 37 }; 38 Maps.organisationScope = $scope; 39 },1000); 40 } 41 42 43 44 45 $scope.$on('NEW_LAYER_ADDED_SUCCESS', function(evt, data){ 46 if($scope.searchName.value == ''){ 47 return; 48 } 49 50 data.name = angular.copy($scope.searchName.value); 51 var colorIndex = 0; 52 if(Maps.customSearches.length > 0){ 53 colorIndex = (Maps.customSearches[Maps.customSearches.length -1].colorIndex + 1) % Maps.randomColorsCount; 54 } 55 data.colorCode = Maps.randomColors[colorIndex]; 56 data.visible = true; 57 data.edit = false; 58 data.organisationsIds = []; 59 angular.forEach(data.organisations, function (organisation){ 60 data.organisationsIds.push(organisation.id); 61 }); 62 $scope.formSearchError = false; 63 64 var res = $scope.addLayerToMap(data, colorIndex); 65 66 data.mapIndex = res.mapIndex; 67 data.colorIndex = res.colorIndex; 68 data.popOverText = $scope.getClusterPopover(data); 69 Maps.customSearches.push(data); 70 Maps.customMap.updateSize(); 71 }); 72 73 $scope.$on('NEW_LAYER_ADDED_ERROR', function(data){ 74 $scope.formSearchError = true; 75 }); 76 77 $scope.addLayerToMap = function(data, index){ 78 79 if(!Maps.customMap) return {}; 80 81 return Maps.addLayerToMap(data, Maps.customMap, index%Maps.randomColorsCount, Maps.customSearches.length, $scope.lang()); 82 } 83 84 $scope.switchVisibility = function(item){ 85 $(Maps.overlayPopup.getElement()).popover('destroy'); 86 Maps.selectCustomMapInteraction.getFeatures().clear(); 87 item.visible = !item.visible; 88 Maps.updateCustomMapVisibility(item.mapIndex, item.visible, Maps.customMap); 89 } 90 91 $scope.printImage = printImage; 92 93 $scope.$on('startPostRequestMap', function(event,args){ 94 printImage(args.array); 95 }); 96 97 98 function printImage(printOptions){ 99 console.log("addedOrganisations",Maps.addedOrganisaitons); 100 101 const exportOptions = { 102 useCORS: true, 103 ignoreElements: function (element) 104 { 105 const className = element.className || ''; 106 return false;
107 // return ( className.includes('ol-control') && !className.includes('ol-scale') && (!className.includes('ol-attribution') || !className.includes('ol-uncollapsible')) ); 108 }, 109 }; 110 111 /* const resolution = 500; 112 const scale = 50; 113 const dim = [500, 500]; 114 115 //const scaleResolution = 2; 116 exportOptions.width = 1827; 117 exportOptions.height = 448;*/ 118 119 html2canvas(Maps.customMap.getViewport(), exportOptions) 120 .then(function (canvas) 121 { 122 var img=canvas.toDataURL("image/png",0.5).replace("image/png", "image/octet-stream"); 123 124 var docFieldList = { 125 linkSocialBrussels : printOptions.linkSocialBrussels, 126 nameOfficial : printOptions.nameOfficial, 127 address : printOptions.address, 128 tel : printOptions.tel , 129 email : printOptions.email, 130 permanency : printOptions.permanency, 131 image: img, 132 sectors : printOptions.sectors, 133 websiteOfficial : printOptions.websiteOfficial, 134 organisationLocationList : Maps.addedOrganisaitons 135 }; 136 137 /* var formData = new FormData(); 138 formData.append('image', canvas.toDataURL("image/png").replace("image/png", "image/octet-stream")); 139 formData.append('docFieldList', docFieldList); 140 */ 141 142 var apiPath = $location.absUrl().replace($location.url(), '') + '/rest/organisation/detailsOrganisationMap/'; 143 $http({ 144 url: apiPath, 145 method: 'POST', 146 responseType: 'blob', 147 data : docFieldList, 148 headers: {'Accept-Language' : $scope.lang(), 'Content-Type' : 'application/json; charset=utf-8' 149 }}) 150 .then(function(response){ 151 var content = response.data; 152 153 //Creating a bloc containing the file data 154 var blob = new Blob([ content ], { type : 'application/octet-stream'}); 155 156 //Getting the file name out of the header 157 var contentDisposition = response.headers('Content-Disposition'); 158 var filename = contentDisposition.split(';')[1].split('filename')[1].split('=')[1].trim(); 159 filename = filename.slice(1); 160 filename = filename.slice(0, filename.length - 1); 161 162 //Creating a link to provoque the downloading 163 var a = document.createElement("a"); 164 a.href = window.URL.createObjectURL(blob); 165 a.download = filename; 166 a.click(); 167 angular.element('#spinnerModal').modal('hide'); 168 }); 169 }) 170 } 171 172 173 174 175 $scope.hasMergeLayer = function(){ 176 if(!Maps.customMap) return; 177 var layer = Maps.customMap.getLayers().item(Maps.mergeLayerIndex).getLayers().item(0); 178 return layer.getSource().getFeatures().length > 0; 179 } 180 181 $scope.defineClusteredLayers = function(){ 182 Maps.clusteredCustomLayers.length = 0; 183 angular.forEach(Maps.customSearches, function(search){ 184 if(search.clustered){ 185 Maps.clusteredCustomLayers.push(search.mapIndex); 186 } 187 }); 188 Maps.showHideCustomClusters(Maps.customMap); 189 } 190 191 $scope.deleteSearch = function(item){ 192 $scope.hideOrganisationPopover(); 193 var index = Maps.customSearches.indexOf(item); 194 var mapIndex = Maps.customSearches[index].mapIndex; 195 for(var i=index+1; i<Maps.customSearches.length; i++){ 196 Maps.customSearches[i].mapIndex--; 197 } 198 Maps.customSearches.splice(index, 1); 199 200 Maps.customMap.removeLayer(Maps.customMap.getLayers().item(mapIndex)); 201 angular.forEach( Maps.customMap.getOverlays().getArray(), function(overlay) { 202 Maps.customMap.removeOverlay(overlay); 203 }); 204 //Remove from clustered list if it was in it 205 $scope.defineClusteredLayers(); 206 //Update merge layer 207 Maps.refreshLayersFeatures(Maps.customMap); 208 //Reset the merge layer visibility and clustering 209 if(Maps.customMap.getLayers().item(Maps.mergeLayerIndex).getLayers().item(0).getSource().getFeatures().length == 0){ 210 $scope.mergeLayerControl.visible = true; 211 $scope.mergeLayerControl.clustered = false;
212 $scope.mergeLayerControl.popOverText = 'organisations.showClusters'; 213 } 214 } 215 216 $scope.setEditName = function(item, value, index){ 217 var element = $("#edit_name_" + index); 218 if(value){ 219 $timeout(function(){ 220 element.focus(); 221 }); 222 } 223 item.edit = value; 224 } 225 226 $scope.sendToMyBruso = function(item){ 227 $scope.selection = {}; 228 $scope.selection.query = item.filters; 229 $scope.selection.title = item.name; 230 $scope.selection.folder = {action: "create"}; 231 } 232 233 $scope.getClusterPopover = function(item){ 234 if(item.clustered){ 235 return 'organisations.showMarkers'; 236 } 237 else{ 238 return 'organisations.showClusters'; 239 } 240 } 241 242 $scope.validateFormName = function(){ 243 $scope.formSearchNameError = false; 244 245 if($scope.searchName.value == ''){ 246 $scope.formSearchNameError = true; 247 } 248 return !$scope.formSearchNameError; 249 } 250 251 $scope.switchClustered = function(item){ 252 $(Maps.overlayPopup.getElement()).popover('destroy'); 253 Maps.selectCustomMapInteraction.getFeatures().clear(); 254 255 item.clustered = !item.clustered; 256 item.popOverText = $scope.getClusterPopover(item); 257 if(item.clustered){ 258 Maps.clusteredCustomLayers.push(item.mapIndex); 259 } 260 else{ 261 var index = Maps.clusteredCustomLayers.indexOf(item.mapIndex); 262 if(index !== -1){ 263 Maps.clusteredCustomLayers.splice(index, 1); 264 } 265 } 266 Maps.showHideCustomClusters(Maps.customMap); 267 } 268 269 $scope.hideOrganisationPopover = function(){ 270 $(Maps.overlayPopup.getElement()).popover('destroy'); 271 Maps.selectCustomMapInteraction.getFeatures().clear(); 272 } 273 274 $scope.setOrganisationToEdit = function(organisation){ 275 $scope.changeRequest = Organisations.createOrganisationChangeRequest(organisation, $scope, $translate); 276 $scope.changeRequestBackup = angular.copy($scope.changeRequest); 277 } 278 } ]); 279})(angular);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.