1//krpano instance 2var krpano = null; 3//trace 4var debug = false; 5//is krpano loaded 6var krpanoLoaded = false; 7//methods to call when plugin is loaded 8var pluginLoaded = new ktools.Map(); 9//is tour started 10var isTourStarted = false; 11//fullscreen object 12var kolorFullscreen = null; 13//browser detection 14var kolorBrowserDetect = null; 15//start z-index value 16var kolorStartIndex = 4000; 17//target url for cross domains application 18var crossDomainTargetUrl = ''; 19var tourLanguage; 20 21if ( debug ) { 22 if ( typeof(console) == 'undefined' ) { 23 console = {log : function (text) {} }; 24 } 25} 26 27/* ======== FULLSCREEN STUFF ========================================== */ 28 29/** 30 * @description Register Fullscreen on DOM ready. 31 */ 32jQuery(document).ready(function() { 33 //add browser detection 34 kolorBrowserDetect = new ktools.BrowserDetect(); 35 kolorBrowserDetect.init(); 36 //kolorBrowserDetect.browser : Browser string 37 //kolorBrowserDetect.version : Browser version 38 //kolorBrowserDetect.OS : Platform OS 39 40 //add fullscreen 41 kolorFullscreen = new ktools.Fullscreen(document.getElementById("tourDIV")); 42 kolorFullscreen.supportsFullscreen(); 43 //activate krpano fallback and update methods 44 kolorFullscreen.setExternal({ 45 'enter': krPanoFullscreenEnter, 46 'exit': krPanoFullscreenExit, 47 'change': krpanoFullscreenChange, 48 'resize': krPanoFullscreenResize 49 }); 50}); 51 52/** 53 * @function 54 * @description Enter fullscreen fallback method for krpano. 55 * @return {void} 56 */ 57function krPanoFullscreenEnter() { 58 var ki = getKrPanoInstance(); 59 if(ki !== null){ 60 getKrPanoInstance().call("enterFullScreenFallback"); 61 } 62} 63 64/** 65 * @function 66 * @description Exit fullscreen fallback method for krpano. 67 * @return {void} 68 */ 69function krPanoFullscreenExit() { 70 var ki = getKrPanoInstance(); 71 if(ki !== null){ 72 ki.call("exitFullScreenFallback"); 73 } 74} 75 76/** 77 * @function 78 * @description Launch method for krpano on fullscreen change event. 79 * @param {Boolean} state If true enter fullscreen event, else exit fullscreen event. 80 * @return {void} 81 */ 82function krpanoFullscreenChange(state) { 83 var ki = getKrPanoInstance(); 84 if(ki !== null){ 85 if(state){ 86 getKrPanoInstance().call("enterFullScreenChangeEvent"); 87 }else{ 88 getKrPanoInstance().call("exitFullScreenChangeEvent"); 89 } 90 } 91} 92 93/** 94 * @function 95 * @description Launch resize method for krpano correct resize. 96 * @return {void} 97 */ 98function krPanoFullscreenResize() { 99 var ki = getKrPanoInstance(); 100 if(ki !== null){ 101 getKrPanoInstance().call("resizeFullScreenEvent"); 102 } 103} 104 105/** 106 * @function 107 * @description Set fullscreen mode. 108 * @param {String|Boolean} value The fullscreen status: 'true' for open or 'false' for close. 109 * @return {void} 110 */ 111function setFullscreen(value) { 112 var state; 113 if(typeof value == "string") 114 state = (value.toLowerCase() == "true"); 115 else 116 state = Boolean(value); 117 118 if (kolorFullscreen) { 119 if(state){ 120 kolorFullscreen.request(); 121 }else{ 122 kolorFullscreen.exit(); 123 } 124 } 125} 126 127/* ========== DIALOG BETWEEN KRPANO/JS STUFF ================================= */ 128 129/** 130 * @function 131 * @description Get krpano instance. 132 * @return {Object} krpano instance. 133 */ 134function getKrPanoInstance() { 135 if ( krpano == null ) { 136 krpano = document.getElementById('krpanoSWFObject'); 137 } 138 return krpano; 139} 140 141/** 142 * @function 143 * @description Call krpano function. 144 * @param {String} fnName The krpano action name. 145 * @param {*} Following parameters are passed to the krPano function 146 * @return {void} 147 */ 148function invokeKrFunction(fnName) { 149 var args = [].slice.call(arguments, 1); 150 var callString = fnName+'('; 151 for(var i=0, ii=args.length; i<ii; i++) 152 { 153 callString += args[i]; 154 if(i != ii-1) { callString += ', '; } 155 } 156 callString += ');'; 157 if(getKrPanoInstance() !== null) 158 { 159 getKrPanoInstance().call(callString); 160 } 161} 162 163/** 164 * @function 165 * @description Get krpano identifier value. 166 * @param {String} identifier The qualifier. 167 * @param {String} type The converting type. Can be: 'int', 'float', 'string', 'boolean', 'object'. 168 * @return {Object} 169 */ 170function getKrValue(identifier, type) { 171 if ( typeof identifier == "undefined" ){ 172 return identifier; 173 } 174
175 if(getKrPanoInstance() !== null) 176 { 177 if(getKrPanoInstance().get(identifier) == null) { 178 return null; 179 } 180 181 switch ( type ) { 182 case "int": 183 return parseInt(getKrPanoInstance().get(identifier)); 184 case "float": 185 return parseFloat(getKrPanoInstance().get(identifier)); 186 case "string": 187 return String(getKrPanoInstance().get(identifier)); 188 case "bool": 189 return Boolean(getKrPanoInstance().get(identifier) === 'true' || parseInt(getKrPanoInstance().get(identifier)) === 1 || getKrPanoInstance().get(identifier) === 'yes' || getKrPanoInstance().get(identifier) === 'on'); 190 default: 191 return getKrPanoInstance().get(identifier); 192 } 193 } 194 else 195 { 196 return null; 197 } 198} 199 200/** 201 * @function 202 * @description Invoke a function of a plugin engine. 203 * @param {String} pluginName The name/id of the plugin. 204 * @param {String} functionName The name of the function to invoke. 205 * @param {Object[]} arguments Additional arguments will be passed to the invoked function as an array. 206 * @return {Object} 207 */ 208function invokePluginFunction(pluginName, functionName) { 209 if ( debug ) { 210 console.log("invokePluginFunction("+pluginName+", "+functionName+")"); 211 } 212 213 var plugin = ktools.KolorPluginList.getInstance().getPlugin(pluginName); 214 if (plugin == null) { 215 if ( debug ) { console.log("invokePluginFunction: plugin instance doesn't exist"); } 216 if(pluginLoaded && pluginLoaded.item(pluginName)){ 217 pluginLoaded.update(pluginName, arguments); 218 }else{ 219 pluginLoaded.add(pluginName, arguments); 220 } 221 return false; 222 } 223 var engine = plugin.getRegistered(); 224 if (engine == null) { 225 if ( debug ) { console.log("invokePluginFunction: plugin isn't registered"); } 226 if(pluginLoaded && pluginLoaded.item(pluginName)){ 227 pluginLoaded.update(pluginName, arguments); 228 }else{ 229 pluginLoaded.add(pluginName, arguments); 230 } 231 return false; 232 } 233 var restArgs = [].slice.call(arguments, 2); 234 return engine[functionName](restArgs); 235} 236 237/** 238 * @function 239 * @description This function is called when krpano is ready. 240 * The ready state of krpano is told by its event onready (in fact it's not fully ready, included XML are not necessarily loaded) 241 * @return {void} 242 */ 243function eventKrpanoLoaded (isWebVr) { 244 if ( debug ) { 245 console.log('krpano is loaded'); 246 } 247 248 if (krpanoLoaded) { return false; } 249 250 tourLanguage = getKrValue("tour_language","string") 251 if(typeof tourLanguage == "undefined"){ 252 tourLanguage = 'kr'; 253 } 254 ktools.I18N.getInstance().initLanguage(tourLanguage, crossDomainTargetUrl+'indexdata/index_messages_','.xml'); 255 krpanoLoaded = true; 256 257 if(isWebVr){ 258 259 260 }else{ 261 262 addKolorArea('description'); 263 264 265addKolorArea('panotourmapsArea'); 266 267 } 268} 269 270/** 271 * @function 272 * @description This function is called when plugins must be unloaded. 273 * @return {void} 274 */ 275function eventUnloadPlugins () { 276 resetValuesForPlugins(); 277 278 279 280deleteKolorMap('panotourmaps'); 281deleteKolorArea('panotourmapsArea'); 282 283deleteKolorArea('description'); 284 285} 286 287/** 288 * @function 289 * @description Reset the default values for the player and plugins loaders. 290 * @return {void} 291 */ 292function resetValuesForPlugins () { 293 krpano = null; 294 krpanoLoaded = false; 295 isTourStarted = false; 296 pluginLoaded = new ktools.Map(); 297 kolorStartIndex = 4000; 298} 299 300/** 301 * @function 302 * @description This function is called when tour is started. 303 * @return {void} 304 */ 305function eventTourStarted () { 306 if ( debug ) { 307 console.log('tour is started'); 308 } 309 310 isTourStarted = true; 311} 312 313/** 314 * @function 315 * @description This function is called when tour language is updated. 316 * @return {void} 317 */ 318function eventTourChangeLanguage (pLang) { 319 if ( debug ) { 320 console.log('change tour language : '+pLang); 321 } 322 323 ktools.I18N.getInstance().initLanguage(pLang, crossDomainTargetUrl+'indexdata/index_messages_','.xml'); 324} 325 326 327/* ========= KOLOR PLUGINS SCRIPTS ============================== */ 328 329 330 331 332 333 334/** ---------------------- Start Plugin Map ----------------------- **/ 335 336//KolorMap api providers 337var KolorMapApiProviders = new Object(); 338KolorMapApiProviders.Type = { googlev3: "googlev3", openlayersv2: "openlayersv2", microsoftv7: "microsoftv7", yandexv2: "yandexv2" }; 339KolorMapApiProviders.Url = { googlev3: "//maps.googleapis.com/ma
339ps/api/js?callback=handleApiReady", 340 openlayersv2: "//cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.js", 341 microsoftv7: "//www.bing.com/api/maps/mapcontrol/?callback=handleApiReady", 342 yandexv2: "//api-maps.yandex.ru/2.0-stable/?load=package.full&lang=ru-RU&onload=handleApiReady" 343 }; 344KolorMapApiProviders.Key = { googlev3: "&key=", openlayersv2: "", microsoftv7: "", yandexv2: "&key=" }; 345KolorMapApiProviders.Script = { googlev3: "mxn.googlev3.core.js", openlayersv2: "mxn.openlayersv2.core.js", microsoftv7: "mxn.microsoftv7.core.js", yandexv2: "mxn.yandexv2.core.js" }; 346 347//store map loaded state 348var mapLoaded = new ktools.Map(); 349var mapLoadedCounter = new ktools.Map(); 350var mapPluginApiReadyCheck = new Array(); 351//store the default marker ID to activate it once registered 352var mapMarkerDefault = new ktools.Map(); 353//validate if the map has been instantiated 354var mapInstance = new ktools.Map(); 355var mapInitCounter = new ktools.Map(); 356 357//Add timestamp to mapstraction library to force IE to reload scripts 358var refreshIE = ""; 359if (navigator.appName == "Microsoft Internet Explorer") { 360 var timestamp = new Date().getTime(); 361 refreshIE = "?v="+timestamp; 362} 363 364//API provider keys 365var microsoftv7_key = ""; 366 367/** 368 * @desc Check if a map API is loaded. 369 * @function 370 * @return {void} 371 */ 372function handleApiReady() { 373 //get first plugName 374 var pluginName = mapPluginApiReadyCheck[0]; 375 376 if( debug ){ 377 console.log('Proprietary map API is loaded for '+pluginName); 378 } 379 380 if( pluginName != null ){ 381 var counter = mapLoadedCounter.item(pluginName) - 1; 382 mapLoadedCounter.update(pluginName, counter); 383 384 if(counter <= 0){ 385 mapLoaded.update(pluginName, true); 386 } 387 388 //remove first plugName 389 mapPluginApiReadyCheck.shift(); 390 } 391} 392 393/** START PLUGIN MAP */ 394 395/** 396 * @desc Add KolorMap plugin instance when krpano is loaded. 397 * @function 398 * @param {String} pluginName The name of the plugin instance. 399 * @param {Object[]} mapsApiArray Array of maps API names and keys couple. 400 * @param {String} mapAreaDiv The map area DOM div name, if exists. 401 * @return {void} 402 */ 403function addKolorMap(pluginName, mapsApiArray, mapAreaDiv){ 404 405 var mapsApiLength = mapsApiArray.length; 406 if(mapsApiLength > 0){ 407 // add map for maps API 408 409 var mapApiOrder = new Array(); 410 var useGoogleLabelsClass = false; 411 var hasOpenlayersMap = false; 412 //loop for maps API and maps API keys construction 413 for(var i=0; i < mapsApiLength; i++){ 414 415 mapPluginApiReadyCheck.push(pluginName); 416 417 switch(mapsApiArray[i][0]){ 418 case "microsoft" : 419 case "microsoft7" : 420 case "microsoftv7" : 421 case "microsoftv8" : 422 //update the microsoft key 423 microsoftv7_key = mapsApiArray[i][1]; 424 mapApiOrder[i] = [KolorMapApiProviders.Type.microsoftv7, KolorMapApiProviders.Url.microsoftv7, KolorMapApiProviders.Key.microsoftv7, KolorMapApiProviders.Script.microsoftv7]; 425 break; 426 case "google" : 427 case "googlev3" : 428 //add key 429 KolorMapApiProviders.Key.googlev3 += mapsApiArray[i][1]; 430 mapApiOrder[i] = [KolorMapApiProviders.Type.googlev3, KolorMapApiProviders.Url.googlev3, KolorMapApiProviders.Key.googlev3, KolorMapApiProviders.Script.googlev3]; 431 useGoogleLabelsClass = true; 432 break; 433 case "yandex" : 434 case "yandexv2" : 435 //add key 436 KolorMapApiProviders.Key.yandexv2 += mapsApiArray[i][1]; 437 mapApiOrder[i] = [KolorMapApiProviders.Type.yandexv2, KolorMapApiProviders.Url.yandexv2, KolorMapApiProviders.Key.yandexv2, KolorMapApiProviders.Script.yandexv2]; 438 break; 439 case "openlayers" : 440 case "openlayersv2" : 441 hasOpenlayersMap = true; 442 mapApiOrder[i] = [KolorMapApiProviders.Type.openlayersv2, KolorMapApiProviders.Url.openlayersv2, KolorMapApiProviders.Key.openlayersv2, KolorMapApiProviders.Script.openlayersv2]; 443 break; 444 } 445 } 446 447 //init values for this plugin 448 mapLoaded.add(pluginName, false); 449 mapMarkerDefault.add(pluginName, {done: false}); 450 mapInstance.add(pluginName, false); 451 //number of maps API to load 452 mapLoadedCounter.add(pluginName, mapsApiLength); 453 mapInitCounter.add(pluginName, 300); //try to load map only during 30 seconds max. 454 455 var mapPlugin = new ktools.KolorPlugin(pluginName); 456 457 // Libraries Dynamic loading 458 var mapApiScript = new ktools.Script(mapApiOrder[0][0], mapApiOrder[0][1]+mapApiOrder[0][2], [], false); 459 460 if (mapsApiLength > 1 && mapApiOrder[1]) { 461 //add second map layer 462 var mapApiScript2 = new ktools.Script(mapApiOrder[1][0], mapApiOrder[1][1]+mapApiOrder[1][2], [mapApiScript], false); 463 if (mapsApiLength > 2 && mapApiOrder[2]) { 464 //add third map layer 465 var mapApiScript3 = new ktools.Script(mapApiOrder[2][0], mapApiOrder[2][1]+mapApiOrder[2][2], [mapApiScript2], false); 466 var mapstractionScript = new ktools.Script("maps_mapstraction", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.js"+refreshIE, [mapApiScript3], false); 467 var mapstractionScriptBase = new ktools.Script("maps_mapstraction_base", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.basemap.js", [mapstractionScript], false); 468 var mapstractionScriptCore = new ktools.Script("maps_mapstraction_core", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.core.js"+refreshIE, [mapstractionScriptBase], false); 469 var mapstractionScriptCoreLayer3 = new ktools.Script("maps_mapstraction_core_layer3", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[2][3]+refreshIE, [mapstractionScriptCore], false); 470 var mapstractionScriptCoreLayer2 = new ktools.Script("maps_mapstraction_core_layer2", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[1][3]+refreshIE, [mapstractionScriptCoreLayer3], false); 471 var mapstractionScriptCoreLayer1 = new ktools.Script("maps_mapstraction_core_layer1", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[0][3]+refreshIE, [mapstractionScriptCoreLayer2], false); 472 } else { 473 if(mapsApiLength > 2){ 474 var tmp_counter = mapLoadedCounter.item(pluginName) - 1; 475 mapLoadedCounter.update(pluginName, tmp_counter); 476 } 477 var mapstractionScript = new ktools.Script("maps_mapstraction", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.js"+refreshIE, [mapApiScript2], false); 478 var mapstractionScriptBase = new ktools.Script("maps_mapstraction_base", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.basemap.js", [mapstractionScript], false); 479 var mapstractionScriptCore = new ktools.Script("maps_mapstraction_core", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.core.js"+refreshIE, [mapstractionScriptBase], false); 480 var mapstractionScriptCoreLayer2 = new ktools.Script("maps_mapstraction_core_layer2", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[1][3]+refreshIE, [mapstractionScriptCore], false); 481 var mapstractionScriptCoreLayer1 = new ktools.Script("maps_mapstraction_core_layer1", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[0][3]+refreshIE, [mapstractionScriptCoreLayer2], false); 482 } 483 } else { 484 if(mapsApiLength > 1){ 485 var tmp_counter = mapLoadedCounter.item(pluginName) - 1; 486 mapLoadedCounter.update(pluginName, tmp_counter); 487 } 488 var mapstractionScript = new ktools.Script("maps_mapstraction", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.js"+refreshIE, [mapApiScript], false); 489 var mapstractionScriptBase = new ktools.Script("maps_mapstraction_base", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.basemap.js", [mapstractionScript], false); 490 var mapstractionScriptCore = new ktools.Script("maps_mapstraction_core", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.core.js"+refreshIE, [mapstractionScriptBase], false); 491 var mapstractionScriptCoreLayer1 = new ktools.Script("maps_mapstraction_core_layer1", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/"+mapApiOrder[0][3]+refreshIE, [mapstractionScriptCore], false); 492 } 493 494 var kolorMapScript = null; 495 if (useGoogleLabelsClass) { 496 var googleLabelsScript = new ktools.Script("maps_google_labels", crossDomainTargetUrl+"indexdata/graphics/KolorMap/lib/mxn.googlev3.core.labels.js", [mapstractionScriptCoreLayer1], false); 497 kolorMapScript = new ktools.Script("kolormap", crossDomainTargetUrl+"indexdata/graphics/KolorMap/js/KolorMap.min.js", [googleLabelsScript], true); 498 } else { 499 kolorMapScript = new ktools.Script("kolormap", crossDomainTargetUrl+"indexdata/graphics/KolorMap/js/KolorMap.min.js", [mapstractionScriptCoreLayer1], true); 500 } 501 mapPlugin.addScript(kolorMapScript); 502 503 var kolorMapCSS = new ktools.CssStyle("kolormapCSS", crossDomainTargetUrl+"indexdata/graphics/KolorMap/js/kolorMap.css"); 504 mapPlugin.addCss(kolorMapCSS); 505 506 ktools.KolorPluginList.getInstance().addPlugin(mapPlugin.getPluginName(), mapPlugin, true); 507 508 if(hasOpenlayersMap){ 509 //delay for 1000ms for OpenLayers only 510 setTimeout(function() { handleApiReady(); }, 1000); 511 } 512 513 //display 514 initKolorMapOnReady(pluginName, mapApiScript.getName(), mapAreaDiv); 515 } 516} 517 518/** 519 * @desc Init the KolorMap script to generate the map. 520 * @function 521 * @param {String} pluginName The name of the plugin instance. 522 * @param {String} defaultMapLayer the default map layer name. 523 * @param {String} mapAreaDiv The map area DOM div name, if exists. 524 * @return {void} 525 */ 526function initKolorMapOnReady(pluginName, defaultMapLayer, mapAreaDiv) { 527 var err = ""; 528 var reload = false;
529 530 if ( !krpanoLoaded ) { 531 err = "throw: krpano is not loaded"; 532 reload = true; 533 } 534 535 if ( !isTourStarted ) { 536 err = "throw: tour is not started"; 537 reload = true; 538 } 539 540 if ( !mapLoaded.item(pluginName) ) { 541 err = "throw: plugin Map is not loaded"; 542 reload = true; 543 } 544 545 //map generation 546 if ( typeof KolorMap == "undefined" || !ktools.KolorPluginList.getInstance().getPlugin(pluginName).isInitialized() ) { 547 err = "throw: KolorMap library not ready"; 548 reload = true; 549 } 550 551 //verify map instance 552 if(mapInstance.item(pluginName) && ktools.KolorPluginList.getInstance().getPlugin(pluginName).getRegistered()){ 553 err = "throw: KolorMap already loaded"; 554 reload = true; 555 }else{ 556 mapInstance.update(pluginName, true); 557 } 558 559 // verify if vr XML plugin is loaded 560 if (getKrValue('ptplugin['+pluginName+'].engine', 'string') == null){ 561 err = "throw: KolorMap can't reach XML yet"; 562 reload = true; 563 } 564 565 // reload init if KolorMap is not ready 566 if(reload){ 567 if ( debug ) { 568 console.log(err); 569 } 570 571 if(mapInitCounter.item(pluginName) > 0){ 572 // start counter only when tour is started 573 if (isTourStarted) { 574 mapInitCounter.update(pluginName, (mapInitCounter.item(pluginName) - 1)); 575 } 576 // if not loaded, retry in 100 ms 577 setTimeout(function() { initKolorMapOnReady(pluginName, defaultMapLayer, mapAreaDiv); }, 100); 578 return; 579 }else{ 580 // FIXME : i18n change text value 581 alert("Connection timeout while making map API call. Try to reload the page."); 582 return; 583 } 584 } 585 586 // prepare multimap swap selector 587 var selectorArray = new Array(); 588 589 //set the default map 590 if (getKrValue('ptplugin['+pluginName+'].multimap', 'bool')) { 591 592 //default map is the first element 593 var defaultMap = new Object(); 594 defaultMap['element'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map.element', 'string'); //sample: 'mapdiv' 595 defaultMap['provider'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map.provider', 'string'); //sample: mapApiScript.getName() 596 defaultMap['name'] = ktools.I18N.getInstance().getMessage(getKrValue('ptplugin['+pluginName+'].multiplemaps.map.name', 'string')); 597 selectorArray[0] = defaultMap; 598 599 kolorMap = new KolorMap(defaultMap.element, defaultMap.provider); 600 }else{ 601 if (mapAreaDiv) { 602 kolorMap = new KolorMap(mapAreaDiv, defaultMapLayer); 603 } else { 604 kolorMap = new KolorMap('mapDIV', defaultMapLayer); 605 } 606 } 607 608 if ( debug ) { 609 console.log("instance: " + kolorMap); 610 } 611 612 //add map default DOM div elements 613 if (mapAreaDiv) { 614 kolorMap.setMapLayer(mapAreaDiv); 615 } else { 616 kolorMap.setMapLayer('mapDIV'); 617 kolorMap.setMapContainer('mapcontainer'); 618 kolorMap.setPanoContainer('panoDIV'); 619 kolorMap.setTourContainer('tourDIV'); 620 } 621 622 //map div position 623 kolorMap.setMapPosition(getKrValue('ptplugin['+pluginName+'].position', 'string')); 624 625 //set zOrder 626 kolorMap.setMapZorder(kolorStartIndex + getKrValue("ptplugin["+pluginName+"].zorder","int")); 627 628 //set url for maps images 629 kolorMap.setGraphicsUrl(crossDomainTargetUrl+"indexdata/graphics/"+pluginName.toLowerCase()+"/"); 630 631 //set color and resizable option 632 kolorMap.setMapResizable(getKrValue('ptplugin['+pluginName+'].resizable', 'bool')); 633 kolorMap.setBgColor(getKrValue('ptplugin['+pluginName+'].bgcolor', 'string')); 634 635 //add the device check 636 kolorMap.setDeviceUsed(getKrValue('vrtourdevice','string')); 637 //kolorMap.setDeviceScale(getKrValue('vrtourdevicescale','float')); 638 639 // set if map must be displayed or hidden 640 var displayOnStart = getKrValue('ptplugin['+pluginName+'].openatstart', 'bool'); 641 642 //init map size into DOM (needed for openlayers API); 643 if (mapAreaDiv) { 644 kolorMap.initMapLayer(); 645 } else { 646 kolorMap.setMapSize(getKrValue('ptplugin['+pluginName+'].size', 'int')); 647 if(displayOnStart){ 648 kolorMap.initMapSize(); 649 kolorMap.initMapLayer(); 650 } 651 } 652 653 //add swap selector 654 if (getKrValue('ptplugin['+pluginName+'].multimap', 'bool')) { 655 656 //second map 657 var secondMap = new Object(); 658 secondMap['element'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map[1].element', 'string'); 659 secondMap['provider'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map[1].provider', 'string'); 660 secondMap['name'] = ktools.I18N.getInstance().getMessage(getKrValue('ptplugin['+pluginName+'].multiplemaps.map[1].name', 'string')); 661 selectorArray[1] = secondMap; 662 //add in DOM 663 jQuery('#mapcontainer').append('<div id="'+secondMap['element']+'"></div>'); 664 665 //third map 666 if (getKrValue('ptplugin['+pluginName+'].multiplemaps.map[2]')) { 667 var thirdMap = new Object(); 668 thirdMap['element'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map[2].element', 'string'); 669 thirdMap['provider'] = getKrValue('ptplugin['+pluginName+'].multiplemaps.map[2].provider', 'string'); 670 thirdMap['name'] = ktools.I18N.getInstance().getMessage(getKrValue('ptplugin['+pluginName+'].multiplemaps.map[2].name', 'string')); 671 selectorArray[2] = thirdMap; 672 //add in DOM 673 jQuery('#mapcontainer').append('<div id="'+thirdMap['element']+'"></div>'); 674 } 675 676 kolorMap.addSwapSelector(pluginName, selectorArray, ktools.I18N.getInstance().getMessage(getKrValue('ptplugin['+pluginName+'].multiplemaps.label', 'string'))); 677 } 678 679 // initialize map position 680 var startPointLat = getKrValue('ptplugin['+pluginName+'].lat', 'float'); 681 var startPointLng = getKrValue('ptplugin['+pluginName+'].lng', 'float'); 682 var startPointZoom = getKrValue('ptplugin['+pluginName+'].zoom','int'); 683 var startPoint = new mxn.LatLonPoint(startPointLat, startPointLng); 684 kolorMap.setStartPoint(startPoint, startPointZoom); 685 kolorMap.getMxnMap().setCenterAndZoom(startPoint, startPointZoom); 686 687 // set map type 688 switch(getKrValue('ptplugin['+pluginName+'].maptypelayer','string')){ 689 case 'satellite': 690 kolorMap.getMxnMap().setMapType(mxn.Mapstraction.SATELLITE); 691 break; 692 case 'hybrid': 693 kolorMap.getMxnMap().setMapType(mxn.Mapstraction.HYBRID); 694 break; 695 case 'physical': 696 kolorMap.getMxnMap().setMapType(mxn.Mapstraction.PHYSICAL); 697 break; 698 default: 699 //'road' 700 kolorMap.getMxnMap().setMapType(mxn.Mapstraction.ROAD); 701 } 702 703 // add controls 704 var useZoom = getKrValue('ptplugin['+pluginName+'].controls.zoom', 'bool'); 705 var usePan = getKrValue('ptplugin['+pluginName+'].controls.pan', 'bool'); 706 var useMapType = getKrValue('ptplugin['+pluginName+'].controls.maptype', 'bool'); 707 var useOverview = getKrValue('ptplugin['+pluginName+'].controls.overview', 'bool'); 708 var useScale = getKrValue('ptplugin['+pluginName+'].controls.scale', 'bool'); 709 var useSpecific = new Object(); 710 if(getKrValue('ptplugin['+pluginName+'].controls.specific')){ 711 if(getKrValue('ptplugin['+pluginName+'].controls.specific.streetview', 'bool')){ 712 useSpecific.streetview = getKrValue('ptplugin['+pluginName+'].controls.specific.streetview', 'bool'); 713 } 714 if(getKrValue('ptplugin['+pluginName+'].controls.specific.view45degree', 'bool')){ 715 useSpecific.view45degree = getKrValue('ptplugin['+pluginName+'].controls.specific.view45degree', 'bool'); 716 } 717 }
718 kolorMap.addControls(useZoom,usePan,useScale,useMapType,useOverview,useSpecific); 719 720 // add ui controls 721 var useDragging = false; 722 var useScroll = false; 723 var useDblClick = false; 724 if(getKrValue('ptplugin['+pluginName+'].controls.ui')){ 725 useDragging = getKrValue('ptplugin['+pluginName+'].controls.ui.draggable', 'bool'); 726 useScroll = getKrValue('ptplugin['+pluginName+'].controls.ui.scrollable', 'bool'); 727 useDblClick = getKrValue('ptplugin['+pluginName+'].controls.ui.dblclick', 'bool'); 728 } 729 kolorMap.getMxnMap().setOption('enableDragging', useDragging); 730 kolorMap.getMxnMap().setOption('enableScrollWheelZoom', useScroll); 731 kolorMap.getMxnMap().setOption('disableDoubleClickZoom', !useDblClick); 732 733 // generate radar(s) 734 var useRadars = false; 735 var radarOptions = {}; 736 if(getKrValue('ptplugin['+pluginName+'].radar.visible','string') == "true"){ 737 useRadars = true; 738 radarOptions = { 739 radius: getKrValue('ptplugin['+pluginName+'].radar.radius','int'), 740 linkToZoom: getKrValue('ptplugin['+pluginName+'].radar.linktozoom','bool'), 741 quality: getKrValue('ptplugin['+pluginName+'].radar.quality','int'), 742 color: getKrValue('ptplugin['+pluginName+'].radar.linecolor','string'), 743 opacity: getKrValue('ptplugin['+pluginName+'].radar.lineopacity','float'), 744 width: getKrValue('ptplugin['+pluginName+'].radar.linewidth','int'), 745 fillColor: getKrValue('ptplugin['+pluginName+'].radar.fillcolor','string'), 746 fillOpacity: getKrValue('ptplugin['+pluginName+'].radar.fillopacity','float'), 747 enginePreset: 0 748 }; 749 } 750 751 // markers animation 752 var useAnimation = false; 753 if(getKrValue('ptplugin['+pluginName+'].markers.animation','string') == "bounce"){ 754 useAnimation = true; 755 } 756 757 // add markers 758 var markersLength = parseInt(getKrPanoInstance().get('ptplugin['+pluginName+'].marker.count')); 759 if(markersLength > 0){ 760 for( var i=0; i < markersLength; i++ ){ 761 var markerId = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].name', 'string'); 762 var markerPointLat = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].lat', 'float'); 763 var markerPointLng = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].lng', 'float'); 764 var markerLatLon = new mxn.LatLonPoint(markerPointLat, markerPointLng); 765 766 // actions 767 var isDraggable = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].draggable', 'bool'); 768 var infoOnHover = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].onhover', 'bool'); 769 var isAnimated = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].animated', 'bool'); 770 771 // icon 772 var iconUrl = ""; 773 var iconSize = null; 774 var iconAnchor = null; 775 var markerIcon = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].markericon','object'); 776 if ( markerIcon != null ) { 777 iconUrl = markerIcon.url; 778 iconSize = new Array(); 779 iconSize[0] = parseInt(markerIcon.iconwidth); 780 iconSize[1] = parseInt(markerIcon.iconheight); 781 iconAnchor = new Array(); 782 switch ( markerIcon.iconanchor.toLowerCase() ) { 783 case "topleft": 784 iconAnchor[0] = 0; 785 iconAnchor[1] = 0; 786 iconAnchor[2] = "topleft"; 787 break; 788 case "top"://topcenter 789 iconAnchor[0] = parseInt(iconSize[0]/2); 790 iconAnchor[1] = 0; 791 iconAnchor[2] = "top"; 792 break; 793 case "topright": 794 iconAnchor[0] = iconSize[0]; 795 iconAnchor[1] = 0; 796 iconAnchor[2] = "topright"; 797 break; 798 case "left"://middleleft 799 iconAnchor[0] = 0; 800 iconAnchor[1] = parseInt(iconSize[1]/2); 801 iconAnchor[2] = "left"; 802 break; 803 case "center"://middlecenter 804 iconAnchor[0] = parseInt(iconSize[1]/2); 805 iconAnchor[1] = parseInt(iconSize[1]/2); 806 iconAnchor[2] = "center"; 807 break; 808 case "right"://middleright 809 iconAnchor[0] = iconSize[0]; 810 iconAnchor[1] = parseInt(iconSize[1]/2); 811 iconAnchor[2] = "right"; 812 break; 813 case "bottomleft": 814 iconAnchor[0] = 0; 815 iconAnchor[1] = iconSize[1]; 816 iconAnchor[2] = "bottomleft"; 817 break; 818 case "bottomright": 819 iconAnchor[0] = iconSize[0]; 820 iconAnchor[1] = iconSize[1]; 821 iconAnchor[2] = "bottomright"; 822 break; 823 default: 824 //"bottom" : bottomcenter 825 iconAnchor[0] = parseInt(iconSize[0]/2); 826 iconAnchor[1] = iconSize[1]; 827 iconAnchor[2] = "bottom"; 828 } 829 } 830 831 // add radar only for scene marker 832 if(useRadars && getKrValue('ptplugin['+pluginName+'].marker[' + i + '].isscene', 'bool') && getKrValue('ptplugin['+pluginName+'].marker[' + i + '].hasradar', 'bool')){ 833 834 // change radar heading 835 var markerPointHeading = getKrValue('ptplugin['+pluginName+'].marker[' + i + '].heading', 'float'); 836 radarOptions.heading = markerPointHeading; 837 838 var aMarkerRadar = kolorMap.addRadar(markerId, markerLatLon, radarOptions); 839 } 840 841 kolorMap.activateMarkersAnimation(useAnimation); 842 843 //add marker (always after radar for openlayers layers z-index) 844 var aMarker = kolorMap.addMarker(markerId, pluginName, markerLatLon, iconUrl, iconSize, iconAnchor, jQuery.trim(ktools.I18N.getInstance().getMessage(getKrValue('ptplugin['+pluginName+'].marker[' + i + '].desc', 'string'))), getKrValue('ptplugin['+pluginName+'].marker[' + i + '].desctype', 'string'), infoOnHover, isDraggable, isAnimated); 845 846 // set the marker's event 847 kolorMap.getMxnMap().addEventListener('click', mapMarkerEvent, aMarker); 848 } 849 } 850 851 //register plugin 852 ktools.KolorPluginList.getInstance().getPlugin(pluginName).register(kolorMap); 853 854 var kolorMapRegistred = ktools.KolorPluginList.getInstance().getPlugin(pluginName).getRegistered(); 855 856 //if the marker ID to activate have been initialized while the map wasn't registered, activate it now 857 if ( kolorMapRegistred ) { 858 859 if (mapMarkerDefault.item(pluginName).done == false) { 860 var applySelection = true; 861 if (getKrValue('ptplugin['+pluginName+'].markerSelected.name','string') != "") { 862 setMapDefaultMarker(pluginName, getKrValue('ptplugin['+pluginName+'].markerSelected.name','string'), getKrValue('ptplugin['+pluginName+'].markerSelected.heading','float'), getKrValue('ptplugin['+pluginName+'].markerSelected.fov','float')); 863 } else if (mapMarkerDefault.item(pluginName).id != undefined) { 864 mapMarkerDefaultArray = [mapMarkerDefault.item(pluginName).id, mapMarkerDefault.item(pluginName).heading, mapMarkerDefault.item(pluginName).fov]; 865 } else { 866 applySelection = false;
867 } 868 869 if (applySelection) { 870 if ( debug ) { 871 console.log("activate the stored marker after init"); 872 } 873 var mapMarkerDefaultArray = [mapMarkerDefault.item(pluginName).id, mapMarkerDefault.item(pluginName).heading, mapMarkerDefault.item(pluginName).fov, getKrValue('ptplugin['+pluginName+'].centeronspots','bool')]; 874 kolorMapRegistred.changeCurrentMarker(mapMarkerDefaultArray); 875 } 876 mapMarkerDefault.update(pluginName, {done: true}); 877 } 878 }else{ 879 if ( debug ) { 880 console.log("KolorMap isn't really loaded"); 881 } 882 mapInstance.update(pluginName, false); 883 //if not loaded, retry in 100 ms 884 setTimeout(function() { initKolorMapOnReady(pluginName, defaultMapLayer, mapAreaDiv); }, 100); 885 return; 886 } 887 888 if (mapAreaDiv) { 889 //force refresh for openlayers 890 kolorMapRegistred.forceResizeMapLayer([mapAreaDiv]); 891 } else { 892 //hide map if needed 893 if(displayOnStart){ 894 kolorMapRegistred.initResizableMap(); 895 }else{ 896 if ( kolorMapRegistred ) { 897 kolorMapRegistred.openCloseMap(["close"]); 898 } 899 } 900 } 901 902 //call ready statement for krpano script 903 invokeKrFunction("kolorMapJsReady_"+pluginName); 904 905 //If a plugin method has been called before registration the method is called now 906 if(pluginLoaded && pluginLoaded.item(pluginName)){ 907 invokePluginFunction.apply(null, pluginLoaded.item(pluginName).funcArgs); 908 pluginLoaded.remove(pluginName); 909 } 910} 911 912/** 913 * @desc Store the map default marker with datas. 914 * @function 915 * @param {String} pluginName The plugin name. 916 * @param {String} markerId The marker ID. 917 * @param {String} krHeading The heading value from krpano. 918 * @param {String} krFov The fov value from krpano. 919 */ 920function setMapDefaultMarker(pluginName, markerId, krHeading, krFov){ 921 var mapMarkerDefaultObject = { id: markerId, heading: krHeading, fov: krFov, done: false }; 922 mapMarkerDefault.update(pluginName, mapMarkerDefaultObject); 923} 924 925/** 926 * @desc Event on a map marker. 927 * @function 928 * @param {String} eventType The type of the event: 'click'. 929 * @param {mxn.Marker} objectSource The marker object. 930 * @param {Object} objdata Structured object additional informations. 931 * @return {void} 932 */ 933function mapMarkerEvent(eventType, objectSource, objdata) { 934 if (debug) { 935 console.log('Map marker event "' + eventType + '" for marker "' + objectSource.getAttribute("id") + '" on plugin "' + objectSource.getAttribute("plugName") + '"'); 936 } 937 938 // if current marker is different select and activate the new marker 939 if ( kolorMap.getActiveMarker() != objectSource ) { 940 var jsMapMarkerAction = objectSource.getAttribute("plugName")+"GoMarker('" + objectSource.getAttribute("id") + "')"; 941 getKrPanoInstance().call(jsMapMarkerAction); 942 } 943 944 // call the marker 'jsclick' action 945 var krMapMarkerAction = getKrValue('ptplugin['+objectSource.getAttribute("plugName")+'].marker[' + objectSource.getAttribute("id") + '].jsclick'); 946 getKrPanoInstance().call(krMapMarkerAction); 947} 948 949/** 950 * @desc Change api provider on the fly for the map. 951 * @function 952 * @param {String} pluginName The plugin name. 953 * @param {String} element The DOM element containing the map layer. 954 * @param {String} api The provider API selected for the map layer element. 955 * @return {void} 956 */ 957function swapProvider(pluginName, element, api){ 958 if ( ktools.KolorPluginList.getInstance().getPlugin(pluginName).getRegistered() != null ) { 959 var kolorMapRegistered = ktools.KolorPluginList.getInstance().getPlugin(pluginName).getRegistered(); 960 kolorMapRegistered.swapProvider([element, api]); 961 } 962} 963 964/** 965 * @function 966 * @description Delete kolorMap. 967 * @param {String} pPlugID The name of the plugin you want to delete. 968 * @return {void} 969 */ 970function deleteKolorMap(pPlugID) 971{ 972 if(ktools.KolorPluginList.getInstance().getPlugin(pPlugID)){ 973 ktools.KolorPluginList.getInstance().removePlugin(pPlugID); 974 } 975} 976 977var kolorMapContainerDOM; 978 979/** 980 * @function 981 * @description Delete kolorMap and the restore the DOM. 982 * @param {String} pPlugID The name of the plugin you want to delete. 983 * @return {void} 984 */ 985function deleteKolorMapDOM(pPlugID) 986{ 987 if(ktools.KolorPluginList.getInstance().getPlugin(pPlugID)){ 988 var kolorMapRegistered = ktools.KolorPluginList.getInstance().getPlugin(pPlugID).getRegistered(); 989 if(kolorMapRegistered) 990 { 991 //delete resizable part 992 kolorMapRegistered.deleteResizableMap(); 993 //restore map container DOM 994 kolorMapRegistered.restoreMapContainerDOM(kolorMapContainerDOM); 995 //resize player div 996 kolorMapRegistered.restorePanoContainerDOM(); 997 } 998 //delete plugin instance 999 deleteKolorMap('panotourmaps'); 1000 } 1001} 1002 1003/** 1004 * @function 1005 * @description Save the kolorMap container initial DOM. 1006 * @return {void} 1007 */ 1008function saveKolorMapContainer() 1009{ 1010 kolorMapContainerDOM = jQuery('#mapcontainer').clone(); 1011} 1012 1013/** ---------------------- End Plugin Map ----------------------- **/ 1014 1015 1016/** 1017 * @function 1018 * @description Add an instance of kolorArea JS Engine, loads JS and CSS files then init and populate related plugin that's based on it. 1019 * @param {String} pPlugID The name of the plugin you want to give to the kolorArea instance. 1020 * @return {void} 1021 */ 1022function addKolorArea(pPlugID) 1023{ 1024 if(typeof ktools.KolorPluginList.getInstance().getPlugin(pPlugID) == "undefined") 1025 { 1026 var kolorAreaCSS = new ktools.CssStyle("KolorAreaCSS", crossDomainTargetUrl+"indexdata/graphics/KolorArea/kolorArea.css"); 1027 var kolorAreaJS = new ktools.Script("KolorAreaJS", crossDomainTargetUrl+"indexdata/graphics/KolorArea/KolorArea.min.js", [], true); 1028 var kolorAreaPlugin = new ktools.KolorPlugin(pPlugID); 1029 kolorAreaPlugin.addScript(kolorAreaJS); 1030 kolorAreaPlugin.addCss(kolorAreaCSS); 1031 ktools.KolorPluginList.getInstance().addPlugin(kolorAreaPlugin.getPluginName(),
1031kolorAreaPlugin, true); 1032 } 1033} 1034 1035/** 1036 * @function 1037 * @description Init, populate and show the kolorArea. 1038 * @param {String} pPlugID The name of the plugin you want to init and show. 1039 * @param {String} pContent The content you want to inject into the kolorArea. I could be HTML string or any other string. 1040 * @return {void} 1041 */ 1042function showKolorArea(pPlugID, pContent) 1043{ 1044 if(debug) { console.log("showKolorArea " + pPlugID); } 1045 1046 //Check if the KolorArea is loaded 1047 if(!ktools.KolorPluginList.getInstance().getPlugin(pPlugID).isInitialized() || typeof KolorArea == "undefined") 1048 { 1049 err = "KolorArea JS is not loaded !"; 1050 if(debug){ console.log(err); } 1051 //If not loaded, retry in 100 ms 1052 setTimeout(function() { showKolorArea(pPlugID, pContent); }, 100); 1053 return; 1054 } 1055 1056 //Check if the KolorArea is instantiate and registered with the ktools.Plugin Object 1057 //If not, instantiate the KolorArea and register it. 1058 if(ktools.KolorPluginList.getInstance().getPlugin(pPlugID).getRegistered() == null) 1059 { 1060 ktools.KolorPluginList.getInstance().getPlugin(pPlugID).register(new KolorArea(pPlugID, "panoDIV")); 1061 } 1062 1063 //Get the registered instance of KolorArea 1064 var kolorArea = ktools.KolorPluginList.getInstance().getPlugin(pPlugID).getRegistered(); 1065 1066 //If kolorArea is not ready, populate datas 1067 if(!kolorArea.isReady()) 1068 { 1069 var kolorAreaOptions = []; 1070 var optionName = ''; 1071 var optionValue = ''; 1072 1073 //Build the Options data for the KolorArea 1074 var optionLength = parseInt(getKrPanoInstance().get("ptplugin["+pPlugID+"].settings.option.count")); 1075 1076 for(var j = 0; j < optionLength; j++) 1077 { 1078 optionName = getKrValue("ptplugin["+pPlugID+"].settings.option["+j+"].name","string"); 1079 if (optionName == 'zorder') { 1080 optionValue = kolorStartIndex + getKrValue("ptplugin["+pPlugID+"].settings.option["+j+"].value", getKrValue("ptplugin["+pPlugID+"].settings.option["+j+"].type", "string")); 1081 } else { 1082 optionValue = getKrValue("ptplugin["+pPlugID+"].settings.option["+j+"].value", getKrValue("ptplugin["+pPlugID+"].settings.option["+j+"].type", "string")); 1083 } 1084 kolorAreaOptions[optionName] = optionValue; 1085 } 1086 //add the device check 1087 kolorAreaOptions['device'] = getKrValue('vrtourdevice','string'); 1088 //kolorAreaOptions['scale'] = getKrValue('vrtourdevicescale','float'); 1089 kolorArea.setKolorAreaOptions(kolorAreaOptions); 1090 1091 //KolorArea is now ready ! 1092 kolorArea.setReady(true); 1093 //call ready statement for krpano script 1094 invokeKrFunction("kolorAreaJsReady_"+pPlugID); 1095 } 1096 1097 kolorArea.setKolorAreaContent(pContent); 1098 kolorArea.openKolorArea(); 1099 1100 //If a plugin method has been called before registration the method is called now 1101 if(pluginLoaded && pluginLoaded.item(pPlugID)){ 1102 invokePluginFunction.apply(null, pluginLoaded.item(pPlugID).funcArgs); 1103 pluginLoaded.remove(pPlugID); 1104 } 1105} 1106 1107/** 1108 * @function 1109 * @description Delete kolorArea. 1110 * @param {String} pPlugID The name of the plugin you want to delete. 1111 * @return {void} 1112 */ 1113function deleteKolorArea(pPlugID) 1114{ 1115 if(ktools.KolorPluginList.getInstance().getPlugin(pPlugID)){ 1116 ktools.KolorPluginList.getInstance().removePlugin(pPlugID); 1117 } 1118 var parent = document.getElementById("panoDIV"); 1119 var child = document.getElementById(pPlugID); 1120 if(parent && child){ 1121 parent.removeChild(child); 1122 } 1123}
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.