1 2 SPFullScreenMode = false; 3 document.addEventListener('fullscreenchange', function() { 4 SPhandleFullscreenChange(); 5 }); 6 document.addEventListener('mozfullscreenchange', function() { // For Firefox 7 SPhandleFullscreenChange(); 8 }); 9 document.addEventListener('webkitfullscreenchange', function() { // For Chrome and Safari 10 SPhandleFullscreenChange(); 11 }); 12 13 function SPhandleFullscreenChange(){ 14 var iframes = document.querySelectorAll('iframe'); 15 iframes.forEach(function(iframe) { 16 var mapDiv = iframe.parentElement; 17 if (mapDiv && mapDiv.spMapSdkInstance) { 18 var isFullscreenNow = !!(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement); 19 mapDiv.spMapSdkInstance.SPFullScreenMode = isFullscreenNow; 20 21 iframe.contentWindow.postMessage({ 22 action: 'fullscreenStatus', 23 isFullscreen: isFullscreenNow 24 }, 'https://streetphonia.com'); // Ensure you specify the correct origin 25 } 26 }); 27 } 28 29 (function(window) { 30 'use strict'; 31 32 // Constructeur de l'objet MapSDK 33 function SPMapSDK(mapDivId, options) { 34 this.mapDiv = document.getElementById(mapDivId); 35 if (!this.mapDiv) { 36 throw new Error("L'élément avec l'ID spécifié n'a pas été trouvé."); 37 } 38 this.mapDiv.spMapSdkInstance = this; 39 40 41 this.options = options || {}; 42 43 if(this.options.zoom == null) 44 this.options.zoom = 18; 45 if(this.options.defaultView == null) 46 this.options.defaultView = 'satellite'; 47 48 if(this.options.mapId == null) 49 alert("Map Id not found"); 50 else 51 this.mapId = this.options.mapId; 52 53 if(this.options.outsideListElement == null) 54 this.outsideListElement = null; 55 else{ 56 57 this.outsideListElement = document.getElementById(this.options.outsideListElement); 58 if (!this.outsideListElement) { 59 throw new Error("L'élément pour afficher la liste avec l'ID spécifié n'a pas été trouvé."); 60 } 61 } 62 63 var urlParams = new URLSearchParams(window.location.search); 64 if (urlParams.has('spElement')) { 65 this.defaultElement = urlParams.get('spElement'); 66 } else { 67 this.defaultElement = ''; // or set to a default value if needed 68 } 69 70 71 72 SPFullScreenMode = false; 73 } 74 75 // Fonction pour générer la carte 76 SPMapSDK.prototype.generateMap = function() { 77 // Create iframe 78 this.iframe = document.createElement('iframe'); 79 this.iframe.src = `https://streetphonia.com/p/StreetPhonia/map/${this.mapId}__${this.defaultElement}/googlemapkey=${this.options.googleMapKey != null ? this.options.googleMapKey:''}/zoom=${this.options.zoom}/defaultView=${this.options.defaultView}/defaultCatType=${this.options.defaultCatType}/hasOutsideList=${this.options.outsideListElement != null ? 'yes':''}`; 80 this.iframe.style.width = '100%'; 81 this.iframe.style.height = '100%'; 82 this.iframe.style.border = 'none'; 83 this.iframe.allow = 'fullscreen;web-share'; 84 85 // Append iframe to mapDiv 86 this.mapDiv.appendChild(this.iframe); 87 88 89 this.iframe.onload = () => { 90 // Post message to the iframe with the correct origin 91 this.iframe.contentWindow.postMessage({ 92 action: 'setParentOrigin', 93 parentUrl: document.location.href // Send the origin as a string 94 }, 'https://streetphonia.com'); // Ensure this matches the iframe's origin 95 }; 96 97 98 if(this.outsideListElement != null){ 99 100 this.outsideListElement.innerHTML = `<iframe name="SPListIframe" src="https://streetphonia.com/p/StreetPhonia/elementsList/${this.mapId}/defaultCatType=${this.options.defaultCatType}" style="width:100%;height:100%;border:none;" allow="fullscreen;web-share"></iframe>`; 101 } 102 103 }; 104 105 106 window.addEventListener('message', function(event) { 107 // Ensure you verify the origin for security reasons 108 if (event.origin !== "https://streetphonia.com") { 109 return; 110 } 111 112 if (event.data.action && event.data.action === 'SPtoggleFullscreen') { 113 var iframeElements = document.querySelectorAll('iframe'); 114 for (var i = 0; i < iframeElements.length; i++) { 115 if (iframeElements[i].contentWindow === event.source) { 116 var mapDiv = iframeElements[i].parentElement; 117 if (mapDiv && mapDiv.spMapSdkInstance ) { 118 mapDiv.spMapSdkInstance.SPtoggleFullscreen(); 119 } 120 } 121 } 122 } 123 124 if (event.data.action && event.data.action === 'SPChangedLanguage') { 125 var iframeElements = document.querySelectorAll('iframe'); 126 var targetIframeName = 'SPListIframe'; // Replace with the actual name of the iframe you want to target 127 128 for (var i = 0; i < iframeElements.length; i++) { 129 if (iframeElements[i].name === targetIframeName) { 130 iframeElements[i].contentWindow.postMessage({ 131 action: 'SPChangedLanguage',
132 language: event.data.language 133 }, 'https://streetphonia.com'); 134 } 135 } 136 } 137 138 if (event.data.action && event.data.action === 'SPChangedCatType') { 139 var iframeElements = document.querySelectorAll('iframe'); 140 var targetIframeName = 'SPListIframe'; // Replace with the actual name of the iframe you want to target 141 142 for (var i = 0; i < iframeElements.length; i++) { 143 if (iframeElements[i].name === targetIframeName) { 144 iframeElements[i].contentWindow.postMessage({ 145 action: 'SPChangedCatType', 146 catType: (Array.isArray(event.data.catType) ? event.data.catType[0] : event.data.catType) 147 }, 'https://streetphonia.com'); 148 } 149 } 150 } 151 152 if (event.data.action && event.data.action === 'SPFocusTo') { 153 var iframeElements = document.querySelectorAll('iframe'); 154 for (var i = 0; i < iframeElements.length; i++) { 155 var mapDiv = iframeElements[i].parentElement; 156 157 if (mapDiv && mapDiv.spMapSdkInstance ) { 158 mapDiv.spMapSdkInstance.SPFocusTo(event.data.element); 159 160 161 if (mapDiv.scrollIntoView ) { 162 mapDiv.scrollIntoView({ behavior: 'smooth', block: 'start' }); 163 } 164 } 165 } 166 } 167 168 if (event.data.action && event.data.action === 'SPChangeCatType') { 169 var iframeElements = document.querySelectorAll('iframe'); 170 for (var i = 0; i < iframeElements.length; i++) { 171 var mapDiv = iframeElements[i].parentElement; 172 if (mapDiv && mapDiv.spMapSdkInstance ) { 173 mapDiv.spMapSdkInstance.SPChangeCat((Array.isArray(event.data.catType) ? event.data.catType[0] : event.data.catType)); 174 } 175 } 176 } 177 178 if (event.data.indexOf && event.data.indexOf('docHeight') > -1) { 179 try { 180 var data = JSON.parse(event.data); 181 182 var iframes = document.querySelectorAll('iframe'); 183 184 for (var i = 0; i < iframes.length; i++) { 185 if (iframes[i].contentWindow === event.source) { 186 if (iframes[i].name === 'SPListIframe') { 187 if (data.docHeight) { 188 iframes[i].style.height = data.docHeight + 'px'; 189 } 190 break; 191 } 192 } 193 } 194 } catch (e) { 195 } 196 } 197 }, false); 198 199 SPMapSDK.prototype.SPChangeCat = function(catType) { 200 if (this.iframe) { 201 this.iframe.contentWindow.postMessage({ 202 action: 'SPChangeCatType', 203 catType: catType 204 }, 'https://streetphonia.com'); // Ensure you specify the correct origin 205 } 206 }; 207 208 SPMapSDK.prototype.SPFocusTo = function(element) { 209 if (this.iframe) { 210 this.iframe.contentWindow.postMessage({ 211 action: 'SPFocusTo', 212 element: element 213 }, 'https://streetphonia.com'); // Ensure you specify the correct origin 214 } 215 }; 216 217 218 // Function to toggle fullscreen 219 SPMapSDK.prototype.SPtoggleFullscreen = function() { 220 if (!SPFullScreenMode) { 221 if (this.mapDiv.requestFullscreen) { 222 this.mapDiv.requestFullscreen(); 223 } else if (this.mapDiv.mozRequestFullScreen) { // For Firefox 224 this.mapDiv.mozRequestFullScreen(); 225 } else if (this.mapDiv.webkitRequestFullscreen) { // For Chrome and Safari 226 this.mapDiv.webkitRequestFullscreen(); 227 } 228 SPFullScreenMode = true; 229 } else { 230 if (document.exitFullscreen) { 231 document.exitFullscreen(); 232 } else if (document.mozCancelFullScreen) { // For Firefox 233 document.mozCancelFullScreen(); 234 } else if (document.webkitExitFullscreen) { // For Chrome and Safari 235 document.webkitExitFullscreen(); 236 } 237 SPFullScreenMode = false; 238 } 239 }; 240 241 window.SPMapSDK = SPMapSDK; 242 243 })(window); 244 245
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.