You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2560 lines
79 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var ActiveZones = null;
  3. var map = null;
  4. var map_ed = null;
  5. var markers = [];
  6. var mapListStore = new Ext.data.JsonStore({
  7. root: 'maps',
  8. totalProperty: 'totalCount',
  9. idProperty: 'map_id',
  10. remoteSort: false,
  11. baseParams: {
  12. UID: '<?=$CUser->Data['id'];?>',
  13. SID: '<?=$Session;?>'//,
  14. //SITE: <?=$SiteID;?>
  15. },
  16. fields: [{
  17. name: 'map_id',
  18. type: 'int'
  19. },{
  20. name: 'map_name',
  21. type: 'string'
  22. }],
  23. proxy : new Ext.data.HttpProxy({
  24. method: 'POST',
  25. prettyUrls: false,
  26. url: '/lib/controller/listMaps.php'
  27. })
  28. });
  29. var selectedMarkerIcon = L.icon({
  30. iconUrl: '/style/assets/cursor.png',
  31. iconSize: [32, 32],
  32. iconAnchor: [16, 16]//,
  33. //popupAnchor: [-3, -76],
  34. //shadowUrl: 'my-icon-shadow.png',
  35. //shadowSize: [68, 95],
  36. //shadowAnchor: [22, 94]
  37. });
  38. selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
  39. function getZoneByNode( nid ){
  40. var rVal = -1;
  41. for( var i=0; i < ActiveZones.totalCount; i++ ){
  42. if( ActiveZones.zones[i].dev_id == nid ){
  43. rVal = i;
  44. break;
  45. };
  46. };
  47. return rVal;
  48. };
  49. function turnOffAllGzButThis( nid ){
  50. var chocho = -1;
  51. for( var i=0; i < ActiveZones.totalCount; i++ ){
  52. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  53. map.removeLayer( ActiveZones.fig[i] );
  54. map.removeLayer( ActiveZones.zang[i] );
  55. map.removeLayer( ActiveZones.center[i] );
  56. };
  57. if( chocho > -1 ){
  58. map.addLayer( ActiveZones.fig[chocho] );
  59. map.addLayer( ActiveZones.zang[chocho] );
  60. map.addLayer( ActiveZones.center[chocho] );
  61. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  62. map.flyToBounds( cVisible.getBounds() );
  63. };
  64. };
  65. function turnAllGzOn(){
  66. var tall = Array();
  67. for( var i=0; i < ActiveZones.totalCount; i++ ){
  68. tall[i*3] = ActiveZones.fig[i];
  69. tall[i*3+1] = ActiveZones.zang[i];
  70. tall[i*3+2] = ActiveZones.center[i];
  71. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  72. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  73. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  74. };
  75. var cVisible = L.featureGroup( tall );
  76. //window.setTimeout(() => {
  77. // map.flyToBounds( cVisible.getBounds() );
  78. //}, 500);
  79. map.flyToBounds( cVisible.getBounds() );
  80. };
  81. function loadMapZones( SiteID ){
  82. Ext.Ajax.request({
  83. url: '/lib/controller/getGeoZones.php',
  84. params: {
  85. SITE: SiteID,
  86. UID: <?=$UserID;?>,
  87. SID: '<?=$Session;?>'
  88. },
  89. success: function( response, opts ){
  90. // If the response is JSON, you have to decode it
  91. var data = Ext.decode(response.responseText);
  92. var pp = Ext.getCmp('sources_panel');
  93. if( typeof pp !== 'undefined' ) pp.removeAll();
  94. ActiveZones = data;
  95. ActiveZones.fig = new Array();
  96. ActiveZones.zang = new Array();
  97. ActiveZones.center = new Array();
  98. for(var i = 0; i < data.totalCount; i++ ) {
  99. switch( data.zones[i].type ){
  100. case 'circle':{
  101. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  102. ActiveZones.fig[i] = new L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } );
  103. //map.addLayer( ActiveZones.fig[i] );
  104. break;
  105. };
  106. case 'poly':{
  107. ActiveZones.fig[i] = new L.polygon( data.zones[i].points, {color: data.zones[i].color, dashArray: "4 1 2 3", weight: 1, opacity: 0.8, clickable: false, interactive: false, bubblingMouseEvents: false });//.addTo(map);
  108. //map.addLayer( ActiveZones.fig[i] );
  109. break;
  110. };
  111. case 'image':{
  112. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  113. //map.addLayer( ActiveZones.fig[i] );
  114. break;
  115. };
  116. case 'image_rot':{
  117. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  118. opacity: 0.8 //,
  119. //interactive: true,
  120. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geogr?fico Nacional de Espa?a</a>"
  121. });//.addTo( map );
  122. //map.addLayer( ActiveZones.fig[i] );
  123. break;
  124. };
  125. };
  126. /*
  127. if( data.zones[i].dev_is_source ){
  128. if( typeof pp !== 'undefined' ) {
  129. var sty = '';
  130. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  131. sty = 'cardDeviceSourceSelected';
  132. } else {
  133. sty = 'cardDeviceSource';
  134. };
  135. pp.add( {
  136. id: data.zones[i].dev_id+'_container',
  137. frame: false,
  138. border: false,
  139. width: 130,
  140. height: 130,
  141. html: '<div id="'+data.zones[i].dev_id+'_div" class="'+sty+'" onclick="clickDeviceSelector('+data.zones[i].dev_id+');"><img id="'+data.zones[i].dev_id+'_ind" width="16px" src="/style/assets/led_green_blink_300ms.gif"><center><img src="/style/assets/'+data.zones[i].dev_type+'_node.png"><br/><p class="dev_name">'+data.zones[i].dev_name+'</p></center></div>'
  142. });
  143. };
  144. };*/
  145. if( data.zones[i].zang != undefined ){
  146. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  147. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  148. };
  149. if( data.zones[i].center != undefined ){
  150. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  151. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  152. };
  153. };
  154. //if( selecredActiveSourceFilter == 0 ){
  155. turnAllGzOn();
  156. //} else {
  157. // turnOffAllGzButThis( selecredActiveSourceFilter );
  158. //};
  159. //if( typeof pp !== 'undefined' ) pp.doLayout();
  160. },
  161. failure: function( response, opts ) {
  162. //Ext.fly('some_div').update('Fail!');
  163. }
  164. });
  165. };
  166. var cevt = Array();
  167. var coz = Array();
  168. function showEventsOnMap( data, removeCursor ){
  169. if( removeCursor == undefined ) removeCursor = true;
  170. if( removeCursor ) map.removeLayer( selectedMarker );
  171. if( cevt.length ){
  172. for( i=0; i< cevt.length; i++ ){
  173. if( cevt[i]!= null ){
  174. cevt[i].remove();
  175. delete( cevt[i] );
  176. cevt[i] = null;
  177. };
  178. };
  179. };
  180. if( coz.length ){
  181. for( i=0; i< coz.length; i++ ){
  182. if( coz[i]!= null ){
  183. coz[i].remove();
  184. delete( coz[i] );
  185. coz[i]=null;
  186. };
  187. };
  188. };
  189. var idx = 0;
  190. for( i=0; i < data.length; i++ ){
  191. if( data[i].targets != undefined ){
  192. var zz = ( 1.0 / ( data[i].targets.length + 0 ) );
  193. var cp_color='#FF0000';
  194. for( j = 0; j < data[i].targets.length; j++ ){
  195. //switch( data.log[i].event ){
  196. // case 36: cp_color='#0000FF'; break;
  197. //};
  198. cLon = data[i].targets[j].lon;
  199. cLat = data[i].targets[j].lat;
  200. cevt[idx] = L.circleMarker( [cLat, cLon], {id:data[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } );//.on('click', function( e, a ){
  201. // loadEventPropertiesByID( this.options.id );
  202. //} );
  203. cevt[idx].addTo(map);
  204. idx++;
  205. };
  206. };
  207. };
  208. };
  209. function LoadMapEventsZ( Mode ){
  210. if( tlLoadLocker ) return;
  211. tlLoadLocker = true;
  212. Ext.Ajax.request({
  213. url: '/lib/controller/getGeoAlerts.php',
  214. params: {
  215. SITE: <?=$SiteID;?>,
  216. UID: <?=$UserID;?>,
  217. SID: '<?=$Session;?>',
  218. MODE: Mode
  219. },
  220. success: function( response, opts ){
  221. if( cevt.length ){
  222. for( i=0; i< cevt.length; i++ ){
  223. if( cevt[i]!= null ){
  224. cevt[i].remove();
  225. delete( cevt[i] );
  226. cevt[i] = null;
  227. };
  228. };
  229. };
  230. if( coz.length ){
  231. for( i=0; i< coz.length; i++ ){
  232. if( coz[i]!= null ){
  233. coz[i].remove();
  234. delete( coz[i] );
  235. coz[i]=null;
  236. };
  237. };
  238. };
  239. var data = Ext.decode( response.responseText );
  240. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  241. for( i=0; i < data.evt.length; i++ ){
  242. cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  243. loadEventProperties( this.options.id );
  244. } );
  245. cevt[i].addTo(map);
  246. };
  247. for( i=0; i < data.other.length; i++ ){
  248. switch( data.other[i].type ){
  249. case 'circle':{
  250. coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } );
  251. coz[i].addTo(map);
  252. break;
  253. };
  254. };
  255. };
  256. //eventsListStore.reload();
  257. tlLoadLocker = false;
  258. },
  259. failure: function( response, opts ) {
  260. //Ext.fly('some_div').update('Fail!');
  261. tlLoadLocker = false;
  262. }
  263. });
  264. };
  265. function initMapMonitoring__00(){
  266. map = L.map('event_map',{
  267. attributionControl: true,
  268. //preferCanvas: true,
  269. zoomControl: true,
  270. center: [SiteLat, SiteLon],
  271. /*zoomControl: false,
  272. zoom: 17,
  273. minZoom: 17,
  274. maxZoom: 17,*/
  275. keyboard: false
  276. }).setView([SiteLat, SiteLon], 17);
  277. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  278. var mapLayers = [];
  279. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  280. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  281. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  282. detectRetina: true
  283. });*/
  284. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  285. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  286. maxNativeZoom: 18,
  287. maxZoom: 24,
  288. })
  289. // https://leaflet-extras.github.io/leaflet-providers/preview/
  290. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  291. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  292. maxZoom: 19
  293. });
  294. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  295. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  296. maxZoom: 19
  297. });
  298. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  299. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  300. maxZoom: 24
  301. });
  302. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  303. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  304. maxZoom: 19
  305. });
  306. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  307. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  308. maxZoom: 19
  309. });
  310. /*
  311. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  312. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  313. maxZoom: 22
  314. });
  315. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  316. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  317. maxZoom: 22
  318. });
  319. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  320. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  321. maxZoom: 22
  322. });
  323. */
  324. var baseMaps = {
  325. "MyMap": mapLayers["MyMap"],
  326. "OpenStreetMap": mapLayers["OpenStreetMap"],
  327. "OpenTopoMap": mapLayers["OpenTopoMap"],
  328. "EsriSat": mapLayers["EsriSat"],
  329. "EsriStreet": mapLayers["EsriStreet"],
  330. "EsriTopo": mapLayers["EsriTopo"],
  331. //"Bing": mapLayers["Bing"],
  332. //"OSM-Cycle": mapLayers["Cycle"],
  333. //"Landscape": mapLayers["Landscape"],
  334. //"Outdoor": mapLayers["Outdoor"],
  335. };
  336. //L.control.layers( baseMaps ).addTo(map);
  337. mapLayers["MyMap"].addTo(map);
  338. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  339. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  340. maxNativeZoom: 18,
  341. maxZoom: 24,
  342. }).addTo(map); */
  343. //loadTimeLineGroups( selectedSite );
  344. loadMapZones( 0 );
  345. //getData( 'arch' );
  346. };
  347. function initMapMonitoring(){
  348. var aK = true;
  349. if( MAP_SET.attribution == '' ) aK = false;
  350. var mapLayers = [];
  351. if( map != null ){
  352. //ToDo: must be moved to Upper Menu changer
  353. map.off();
  354. map.remove();
  355. map = null;
  356. };
  357. switch( MAP_SET.type ){
  358. case 1: {
  359. map = L.map( 'event_map',{
  360. //attributionControl: aK,
  361. attributionControl: false,
  362. preferCanvas: true,
  363. zoomControl: true,
  364. center: [SiteLat, SiteLon],
  365. /*zoomControl: false,
  366. zoom: 17,
  367. minZoom: 17,
  368. maxZoom: 17,*/
  369. keyboard: false
  370. });
  371. map.setView([SiteLat, SiteLon], 17 );
  372. //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
  373. // attribution: MAP_SET.attribution,
  374. // maxNativeZoom: MAP_SET.maxNativeZoom,
  375. // maxZoom: MAP_SET.maxZoom
  376. //});
  377. L.tileLayer( MAP_SET.layer_url, {
  378. attribution: MAP_SET.attribution,
  379. attributionControl: false,
  380. maxNativeZoom: MAP_SET.maxNativeZoom,
  381. //minZoom: 0,
  382. maxZoom: MAP_SET.maxZoom
  383. }).addTo( map );
  384. break;
  385. };
  386. case 2:{
  387. map = L.map( 'event_map',{
  388. crs: L.CRS.Simple,
  389. attributionControl: false,
  390. preferCanvas: true,
  391. zoomControl: true,
  392. center: [SiteLat, SiteLon],
  393. /*zoomControl: false,*/
  394. zoom: 2,
  395. minZoom: -1,
  396. maxZoom: 4,
  397. keyboard: false
  398. });
  399. var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
  400. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
  401. //map.setView([SiteLat, SiteLon], -1 );
  402. break;
  403. };
  404. case 3:{
  405. map = L.map( 'event_map',{
  406. attributionControl: false,
  407. preferCanvas: true,
  408. zoomControl: true,
  409. center: [SiteLat,SiteLon],
  410. zoom: MAP_SET.maxZoom - 2,
  411. minZoom: MAP_SET.maxZoom - 4,
  412. maxZoom: MAP_SET.maxZoom,
  413. keyboard: false
  414. });
  415. var bounds = [[MAP_SET.bounds_ly,MAP_SET.bounds_lx], [MAP_SET.bounds_ry,MAP_SET.bounds_rx]];
  416. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
  417. break;
  418. };
  419. };
  420. //ToDo: Fix Initial Zoom level -> May be saving into a user profile
  421. loadMapZones( 0 );
  422. };
  423. function initMapReporting(){
  424. var aK = true;
  425. if( MAP_SET.attribution == '' ) aK = false;
  426. var mapLayers = [];
  427. if( map != null ){
  428. //ToDo: must be moved to Upper Menu changer
  429. map.off();
  430. map.remove();
  431. map = null;
  432. };
  433. switch( MAP_SET.type ){
  434. case 1:{
  435. map = L.map( 'report_map',{
  436. //attributionControl: aK,
  437. attributionControl: false,
  438. preferCanvas: true,
  439. zoomControl: true,
  440. center: [SiteLat, SiteLon],
  441. /*zoomControl: false,
  442. zoom: 17,
  443. minZoom: 17,
  444. maxZoom: 17,*/
  445. keyboard: false
  446. });
  447. map.setView([SiteLat, SiteLon], 17 );
  448. //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
  449. // attribution: MAP_SET.attribution,
  450. // maxNativeZoom: MAP_SET.maxNativeZoom,
  451. // maxZoom: MAP_SET.maxZoom
  452. //});
  453. L.tileLayer( MAP_SET.layer_url, {
  454. attribution: MAP_SET.attribution,
  455. attributionControl: false,
  456. maxNativeZoom: MAP_SET.maxNativeZoom,
  457. minZoom: 0,
  458. maxZoom: MAP_SET.maxZoom
  459. }).addTo( map );
  460. break;
  461. };
  462. case 2:{
  463. map = L.map( 'report_map',{
  464. crs: L.CRS.Simple,
  465. attributionControl: false,
  466. preferCanvas: true,
  467. zoomControl: true,
  468. center: [SiteLat, SiteLon],
  469. /*zoomControl: false,*/
  470. zoom: 0,
  471. minZoom: -1,
  472. maxZoom: 4,
  473. keyboard: false
  474. });
  475. var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
  476. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
  477. //map.setView([SiteLat, SiteLon], -1 );
  478. break;
  479. };
  480. case 3:{
  481. map = L.map( 'report_map',{
  482. attributionControl: false,
  483. preferCanvas: true,
  484. zoomControl: true,
  485. center: [SiteLat,SiteLon],
  486. zoom: MAP_SET.maxZoom - 2,
  487. minZoom: MAP_SET.maxZoom - 4,
  488. maxZoom: MAP_SET.maxZoom,
  489. keyboard: false
  490. });
  491. var bounds = [[MAP_SET.bounds_ly,MAP_SET.bounds_lx], [MAP_SET.bounds_ry,MAP_SET.bounds_rx]];
  492. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
  493. break;
  494. };
  495. };
  496. //ToDo: Fix Initial Zoom level -> May be saving into a user profile
  497. loadMapZones( 0 );
  498. };
  499. var iconSaver = null;
  500. var markerSaver = null;
  501. function updateLocation( e ){
  502. locationSelectedNode = e.target.options.mycustomid;
  503. Ext.Ajax.request({
  504. url: '/lib/controller/updateLocation.php',
  505. params: {
  506. NODE: locationSelectedNode,
  507. SITE: <?=$SiteID;?>,
  508. UID: <?=$UserID;?>,
  509. TYPE: 0,
  510. SID: '<?=$Session;?>',
  511. LAT: e.target._latlng.lat,
  512. LON: e.target._latlng.lng
  513. },
  514. success: function( response, opts ){
  515. loadNodeLocationProps( locationSelectedNode );
  516. },
  517. failure: failureAJAXFunction
  518. });
  519. };
  520. function markerDblClick( e ){
  521. if( iconSaver == null ){
  522. iconSaver = e.target.options.icon;
  523. markerSaver = e.target;
  524. e.target.setIcon( SNAPE_Icon );
  525. for( i=0; i< markers.length; i++){
  526. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  527. markers[i].setOpacity( 0.1 );
  528. } else {
  529. markers[i].setOpacity( 1.0 );
  530. }
  531. };
  532. } else {
  533. if( e.target.options.mycustomid == markerSaver.options.mycustomid ){
  534. e.target.setIcon( iconSaver );
  535. iconSaver = null;
  536. markerSaver = null;
  537. for( i=0; i< markers.length; i++){
  538. markers[i].setOpacity( 1.0 );
  539. };
  540. } else {
  541. markerSaver.setIcon( iconSaver );
  542. iconSaver = e.target.options.icon;
  543. markerSaver = e.target;
  544. e.target.setIcon( SNAPE_Icon );
  545. for( i=0; i< markers.length; i++){
  546. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  547. markers[i].setOpacity( 0.1 );
  548. } else {
  549. markers[i].setOpacity( 1.0 );
  550. }
  551. };
  552. };
  553. };
  554. };
  555. function setNodeLocationToAnchor(){
  556. Ext.Ajax.request({
  557. url: '/lib/controller/updateLocation.php',
  558. params: {
  559. NODE: locationSelectedNode,
  560. SITE: <?=$SiteID;?>,
  561. UID: <?=$UserID;?>,
  562. TYPE: 0,
  563. SID: '<?=$Session;?>',
  564. LAT: SiteLat,
  565. LON: SiteLon,
  566. ALT: SiteAlt
  567. },
  568. success: function( response, opts ){
  569. loadLocationEditor('sys_location_map');
  570. },
  571. failure: failureAJAXFunction
  572. });
  573. };
  574. function setNodeLocationByDelta(){
  575. var dx = Ext.getCmp('dx').getValue();
  576. var dy = Ext.getCmp('dy').getValue();
  577. var dz = Ext.getCmp('dz').getValue();
  578. Ext.Ajax.request({
  579. url: '/lib/controller/updateLocation.php',
  580. params: {
  581. NODE: locationSelectedNode,
  582. SITE: <?=$SiteID;?>,
  583. UID: <?=$UserID;?>,
  584. TYPE: 3,
  585. SID: '<?=$Session;?>',
  586. LAT: dx,
  587. LON: dy,
  588. ALT: dz
  589. },
  590. success: function( response, opts ){
  591. loadLocationEditor('sys_location_map');
  592. },
  593. failure: failureAJAXFunction
  594. });
  595. };
  596. //viewport
  597. function Events() {
  598. this.events = { };
  599. }
  600. Events.prototype.on = function(name, fn) {
  601. var events = this.events[name];
  602. if (events == undefined) {
  603. this.events[name] = [ fn ];
  604. this.emit('event:on', fn);
  605. } else {
  606. if (events.indexOf(fn) == -1) {
  607. events.push(fn);
  608. this.emit('event:on', fn);
  609. }
  610. }
  611. return this;
  612. }
  613. Events.prototype.once = function(name, fn) {
  614. var events = this.events[name];
  615. fn.once = true;
  616. if (!events) {
  617. this.events[name] = [ fn ];
  618. this.emit('event:once', fn);
  619. } else {
  620. if (events.indexOf(fn) == -1) {
  621. events.push(fn);
  622. this.emit('event:once', fn);
  623. }
  624. }
  625. return this;
  626. }
  627. Events.prototype.emit = function(name, args) {
  628. var events = this.events[name];
  629. if (events) {
  630. var i = events.length;
  631. while(i--) {
  632. if (events[i]) {
  633. events[i].call(this, args);
  634. if (events[i].once) {
  635. delete events[i];
  636. }
  637. }
  638. }
  639. }
  640. return this;
  641. }
  642. Events.prototype.unbind = function(name, fn) {
  643. if (name) {
  644. var events = this.events[name];
  645. if (events) {
  646. if (fn) {
  647. var i = events.indexOf(fn);
  648. if (i != -1) {
  649. delete events[i];
  650. }
  651. } else {
  652. delete this.events[name];
  653. }
  654. }
  655. } else {
  656. delete this.events;
  657. this.events = { };
  658. }
  659. return this;
  660. }
  661. var userPrefix;
  662. var prefix = (function () {
  663. var styles = window.getComputedStyle(document.documentElement, ''),
  664. pre = (Array.prototype.slice
  665. .call(styles)
  666. .join('')
  667. .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
  668. )[1],
  669. dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
  670. userPrefix = {
  671. dom: dom,
  672. lowercase: pre,
  673. css: '-' + pre + '-',
  674. js: pre[0].toUpperCase() + pre.substr(1)
  675. };
  676. })();
  677. function bindEvent(element, type, handler) {
  678. if(element.addEventListener) {
  679. element.addEventListener(type, handler, false);
  680. } else {
  681. element.attachEvent('on' + type, handler);
  682. }
  683. }
  684. function Viewport(data) {
  685. events.add( this );
  686. var self = this;
  687. this.element = data.element;
  688. this.fps = data.fps;
  689. this.sensivity = data.sensivity;
  690. this.sensivityFade = data.sensivityFade;
  691. this.touchSensivity = data.touchSensivity;
  692. this.speed = data.speed;
  693. this.lastX = 0;
  694. this.lastY = 0;
  695. this.mouseX = 0;
  696. this.mouseY = 0;
  697. this.distanceX = 0;
  698. this.distanceY = 0;
  699. this.positionX = 0;
  700. this.positionY = 0;
  701. this.positionZ = 0;
  702. this.torqueX = 0;
  703. this.torqueY = 0;
  704. this.down = false;
  705. this.upsideDown = false;
  706. this.previousPositionX = 0;
  707. this.previousPositionY = 0;
  708. this.previousPositionZ = 0;
  709. this.currentSide = 0;
  710. this.calculatedSide = 0;
  711. bindEvent(data.element /*document*/, 'mousedown', function() { self.down = true; });
  712. bindEvent(data.element, 'mouseup', function() { self.down = false; });
  713. bindEvent(data.element, 'keyup', function() { self.down = false; });
  714. bindEvent(data.element, 'mousemove', function(e) { self.mouseX = e.pageX; self.mouseY = e.pageY; });
  715. bindEvent(data.element, 'touchstart', function(e) {
  716. self.down = true;
  717. e.touches ? e = e.touches[0] : null;
  718. self.mouseX = e.pageX / self.touchSensivity;
  719. self.mouseY = e.pageY / self.touchSensivity;
  720. self.lastX = self.mouseX;
  721. self.lastY = self.mouseY;
  722. });
  723. bindEvent(data.element, 'touchmove', function(e) {
  724. if(e.preventDefault) {
  725. e.preventDefault();
  726. }
  727. if(e.touches.length == 1) {
  728. e.touches ? e = e.touches[0] : null;
  729. self.mouseX = e.pageX / self.touchSensivity;
  730. self.mouseY = e.pageY / self.touchSensivity;
  731. }
  732. });
  733. bindEvent(data.element, 'touchend', function(e) {
  734. self.down = false;
  735. });
  736. setInterval(this.animate.bind(this), this.fps);
  737. }
  738. var events = new Events();
  739. events.add = function(obj) {
  740. obj.events = { };
  741. }
  742. events.implement = function(fn) {
  743. fn.prototype = Object.create(Events.prototype);
  744. }
  745. events.implement(Viewport);
  746. Viewport.prototype.animate = function() {
  747. this.distanceX = (this.mouseX - this.lastX);
  748. this.distanceY = (this.mouseY - this.lastY);
  749. this.lastX = this.mouseX;
  750. this.lastY = this.mouseY;
  751. if(this.down) {
  752. this.torqueX = this.torqueX * this.sensivityFade + (this.distanceX * this.speed - this.torqueX) * this.sensivity;
  753. this.torqueY = this.torqueY * this.sensivityFade + (this.distanceY * this.speed - this.torqueY) * this.sensivity;
  754. }
  755. if(Math.abs(this.torqueX) > 1.0 || Math.abs(this.torqueY) > 1.0) {
  756. if(!this.down) {
  757. this.torqueX *= this.sensivityFade;
  758. this.torqueY *= this.sensivityFade;
  759. }
  760. this.positionY -= this.torqueY;
  761. if(this.positionY > 360) {
  762. this.positionY -= 360;
  763. } else if(this.positionY < 0) {
  764. this.positionY += 360;
  765. }
  766. if(this.positionY > 90 && this.positionY < 270) {
  767. this.positionX -= this.torqueX;
  768. if(!this.upsideDown) {
  769. this.upsideDown = true;
  770. this.emit('upsideDown', { upsideDown: this.upsideDown });
  771. }
  772. } else {
  773. this.positionX += this.torqueX;
  774. if(this.upsideDown) {
  775. this.upsideDown = false;
  776. this.emit('upsideDown', { upsideDown: this.upsideDown });
  777. }
  778. }
  779. if(this.positionX > 360) {
  780. this.positionX -= 360;
  781. } else if(this.positionX < 0) {
  782. this.positionX += 360;
  783. }
  784. if(!(this.positionY >= 46 && this.positionY <= 130) && !(this.positionY >= 220 && this.positionY <= 308)) {
  785. if(this.upsideDown) {
  786. if(this.positionX >= 42 && this.positionX <= 130) {
  787. this.calculatedSide = 3;
  788. } else if(this.positionX >= 131 && this.positionX <= 223) {
  789. this.calculatedSide = 2;
  790. } else if(this.positionX >= 224 && this.positionX <= 314) {
  791. this.calculatedSide = 5;
  792. } else {
  793. this.calculatedSide = 4;
  794. }
  795. } else {
  796. if(this.positionX >= 42 && this.positionX <= 130) {
  797. this.calculatedSide = 5;
  798. } else if(this.positionX >= 131 && this.positionX <= 223) {
  799. this.calculatedSide = 4;
  800. } else if(this.positionX >= 224 && this.positionX <= 314) {
  801. this.calculatedSide = 3;
  802. } else {
  803. this.calculatedSide = 2;
  804. }
  805. }
  806. } else {
  807. if(this.positionY >= 46 && this.positionY <= 130) {
  808. this.calculatedSide = 6;
  809. }
  810. if(this.positionY >= 220 && this.positionY <= 308) {
  811. this.calculatedSide = 1;
  812. }
  813. }
  814. if(this.calculatedSide !== this.currentSide) {
  815. this.currentSide = this.calculatedSide;
  816. this.emit('sideChange');
  817. }
  818. }
  819. this.element.style[userPrefix.js + 'Transform'] = 'rotateX(' + this.positionY + 'deg) rotateY(' + this.positionX + 'deg) rotateZ('+this.positionZ + 'deg)';
  820. if(this.positionY != this.previousPositionY || this.positionX != this.previousPositionX || this.positionZ != this.previousPositionZ ) {
  821. this.previousPositionY = this.positionY;
  822. this.previousPositionX = this.positionX;
  823. this.previousPositionZ = this.positionZ;
  824. this.emit('rotate');
  825. }
  826. }
  827. Viewport.prototype.setDirect = function( A, B, C ) {
  828. if( 1 ) {
  829. this.positionX = A;
  830. this.positionY = B;
  831. this.positionZ = C;
  832. if(this.positionY > 360) {
  833. this.positionY -= 360;
  834. } else if(this.positionY < 0) {
  835. this.positionY += 360;
  836. }
  837. if(this.positionY > 90 && this.positionY < 270) {
  838. if(!this.upsideDown) {
  839. this.upsideDown = true;
  840. this.emit('upsideDown', { upsideDown: this.upsideDown });
  841. }
  842. } else {
  843. if(this.upsideDown) {
  844. this.upsideDown = false;
  845. this.emit('upsideDown', { upsideDown: this.upsideDown });
  846. }
  847. }
  848. if(this.positionX > 360) {
  849. this.positionX -= 360;
  850. } else if(this.positionX < 0) {
  851. this.positionX += 360;
  852. }
  853. if(!(this.positionY >= 46 && this.positionY <= 130) && !(this.positionY >= 220 && this.positionY <= 308)) {
  854. if(this.upsideDown) {
  855. if(this.positionX >= 42 && this.positionX <= 130) {
  856. this.calculatedSide = 3;
  857. } else if(this.positionX >= 131 && this.positionX <= 223) {
  858. this.calculatedSide = 2;
  859. } else if(this.positionX >= 224 && this.positionX <= 314) {
  860. this.calculatedSide = 5;
  861. } else {
  862. this.calculatedSide = 4;
  863. }
  864. } else {
  865. if(this.positionX >= 42 && this.positionX <= 130) {
  866. this.calculatedSide = 5;
  867. } else if(this.positionX >= 131 && this.positionX <= 223) {
  868. this.calculatedSide = 4;
  869. } else if(this.positionX >= 224 && this.positionX <= 314) {
  870. this.calculatedSide = 3;
  871. } else {
  872. this.calculatedSide = 2;
  873. }
  874. }
  875. } else {
  876. if(this.positionY >= 46 && this.positionY <= 130) {
  877. this.calculatedSide = 6;
  878. }
  879. if(this.positionY >= 220 && this.positionY <= 308) {
  880. this.calculatedSide = 1;
  881. }
  882. }
  883. if(this.calculatedSide !== this.currentSide) {
  884. this.currentSide = this.calculatedSide;
  885. this.emit('sideChange');
  886. }
  887. }
  888. this.element.style[userPrefix.js + 'Transform'] = 'rotateX(' + this.positionY + 'deg) rotateY(' + this.positionX + 'deg) rotateZ('+this.positionZ + 'deg)';
  889. if(this.positionY != this.previousPositionY || this.positionX != this.previousPositionX || this.positionZ != this.previousPositionZ ) {
  890. this.previousPositionY = this.positionY;
  891. this.previousPositionX = this.positionX;
  892. this.previousPositionZ = this.positionZ;
  893. this.emit('rotate');
  894. }
  895. }
  896. function Cube(data) {
  897. var self = this;
  898. this.element = data.element;
  899. this.sides = this.element.getElementsByClassName('side');
  900. this.viewport = data.viewport;
  901. this.viewport.on('rotate', function() {
  902. self.rotateSides();
  903. });
  904. this.viewport.on('upsideDown', function(obj) {
  905. self.upsideDown(obj);
  906. });
  907. this.viewport.on('sideChange', function() {
  908. self.sideChange();
  909. });
  910. }
  911. Cube.prototype.rotateSides = function() {
  912. var viewport = this.viewport;
  913. if(viewport.positionY > 90 && viewport.positionY < 270) {
  914. this.sides[0].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + (viewport.positionX + viewport.torqueX) + 'deg)';
  915. this.sides[5].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + -(viewport.positionX + 180 + viewport.torqueX) + 'deg)';
  916. } else {
  917. this.sides[0].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + (viewport.positionX - viewport.torqueX) + 'deg)';
  918. this.sides[5].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + -(viewport.positionX + 180 - viewport.torqueX) + 'deg)';
  919. }
  920. }
  921. Cube.prototype.upsideDown = function(obj) {
  922. var deg = (obj.upsideDown == true) ? '180deg' : '0deg';
  923. var i = 5;
  924. while(i > 0 && --i) {
  925. this.sides[i].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + deg + ')';
  926. }
  927. }
  928. Cube.prototype.sideChange = function() {
  929. for(var i = 0; i < this.sides.length; ++i) {
  930. this.sides[i].getElementsByClassName('cube-image')[0].className = 'cube-image';
  931. }
  932. this.sides[this.viewport.currentSide - 1].getElementsByClassName('cube-image')[0].className = 'cube-image active';
  933. }
  934. Cube.prototype.set = function( A, B, C ) {
  935. //C = C + 90.0;
  936. this.viewport.setDirect( A, B, C );
  937. }
  938. //var viewport = new Viewport({
  939. // element: document.getElementsByClassName('cube')[0],
  940. // fps: 20,
  941. // sensivity: .1,
  942. // sensivityFade: .93,
  943. // speed: 2,
  944. // touchSensivity: 1.5
  945. //});
  946. //new Cube({
  947. // viewport: viewport,
  948. // element: document.getElementsByClassName('cube')[0]
  949. //});
  950. var LRF3D_Icon = L.icon({
  951. iconUrl: '/style/assets/5_node.png',
  952. //shadowUrl: 'leaf-shadow.png',
  953. iconSize: [64, 64], // size of the icon
  954. //shadowSize: [50, 64], // size of the shadow
  955. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  956. //shadowAnchor: [4, 62], // the same for the shadow
  957. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  958. });
  959. var LFS_Icon = L.icon({
  960. iconUrl: '/style/assets/2_node.png',
  961. //shadowUrl: 'leaf-shadow.png',
  962. iconSize: [64, 64], // size of the icon
  963. //shadowSize: [50, 64], // size of the shadow
  964. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  965. //shadowAnchor: [4, 62], // the same for the shadow
  966. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  967. });
  968. var PLS200_Icon = L.icon({
  969. iconUrl: '/style/assets/3_node.png',
  970. //shadowUrl: 'leaf-shadow.png',
  971. iconSize: [64, 64], // size of the icon
  972. //shadowSize: [50, 64], // size of the shadow
  973. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  974. //shadowAnchor: [4, 62], // the same for the shadow
  975. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  976. });
  977. var PLSNET200_Icon = L.icon({
  978. iconUrl: '/style/assets/6_node.png',
  979. //shadowUrl: 'leaf-shadow.png',
  980. iconSize: [64, 64], // size of the icon
  981. //shadowSize: [50, 64], // size of the shadow
  982. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  983. //shadowAnchor: [4, 62], // the same for the shadow
  984. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  985. });
  986. var PLS360_Icon = L.icon({
  987. iconUrl: '/style/assets/4_node.png',
  988. //shadowUrl: 'leaf-shadow.png',
  989. iconSize: [64, 64], // size of the icon
  990. //shadowSize: [50, 64], // size of the shadow
  991. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  992. //shadowAnchor: [4, 62], // the same for the shadow
  993. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  994. });
  995. var ALS_Icon = L.icon({
  996. iconUrl: '/style/assets/1_node.png',
  997. //shadowUrl: 'leaf-shadow.png',
  998. iconSize: [64, 64], // size of the icon
  999. //shadowSize: [50, 64], // size of the shadow
  1000. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  1001. //shadowAnchor: [4, 62], // the same for the shadow
  1002. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  1003. });
  1004. var PTZCAM_Icon = L.icon({
  1005. iconUrl: '/style/assets/12_node.png',
  1006. //shadowUrl: 'leaf-shadow.png',
  1007. iconSize: [64, 64], // size of the icon
  1008. //shadowSize: [50, 64], // size of the shadow
  1009. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  1010. //shadowAnchor: [4, 62], // the same for the shadow
  1011. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  1012. });
  1013. var FIXCAM_Icon = L.icon({
  1014. iconUrl: '/style/assets/11_node.png',
  1015. //shadowUrl: 'leaf-shadow.png',
  1016. iconSize: [64, 64], // size of the icon
  1017. //shadowSize: [50, 64], // size of the shadow
  1018. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  1019. //shadowAnchor: [4, 62], // the same for the shadow
  1020. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  1021. });
  1022. var SITEZ_Icon = L.icon({
  1023. iconUrl: '/style/assets/centre_1.png',
  1024. //shadowUrl: 'leaf-shadow.png',
  1025. iconSize: [32, 32], // size of the icon
  1026. //shadowSize: [50, 64], // size of the shadow
  1027. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  1028. //shadowAnchor: [4, 62], // the same for the shadow
  1029. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  1030. });
  1031. var SNAPE_Icon = L.icon({
  1032. iconUrl: '/style/assets/cursor.png',
  1033. //shadowUrl: 'leaf-shadow.png',
  1034. iconSize: [32, 32], // size of the icon
  1035. //shadowSize: [50, 64], // size of the shadow
  1036. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  1037. //shadowAnchor: [4, 62], // the same for the shadow
  1038. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  1039. });
  1040. function loadLocationNodes(){
  1041. Ext.Ajax.request({
  1042. url: '/lib/controller/getLocationItems.php',
  1043. params: {
  1044. SITE: <?=$SiteID;?>,
  1045. UID: <?=$UserID;?>,
  1046. SID: '<?=$Session;?>'
  1047. },
  1048. success: function( response, opts ){
  1049. var data = Ext.decode(response.responseText);
  1050. if( data!= null ){
  1051. var i = 0;
  1052. var tall = Array();
  1053. for( ; i < data.length; i++){
  1054. switch( data[i].type ){
  1055. case 1:{
  1056. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1057. break;
  1058. };
  1059. case 2:{
  1060. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LFS_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1061. break;
  1062. };
  1063. case 3:{
  1064. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS200_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1065. break;
  1066. };
  1067. case 4:{
  1068. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS360_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1069. break;
  1070. };
  1071. case 5:{
  1072. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LRF3D_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1073. break;
  1074. };
  1075. case 6:{
  1076. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLSNET200_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1077. break;
  1078. };
  1079. case 10:
  1080. case 12:{
  1081. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: FIXCAM_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1082. break;
  1083. };
  1084. case 11:
  1085. case 13:{
  1086. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PTZCAM_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1087. break;
  1088. };
  1089. };
  1090. tall[i] = markers[i];
  1091. };
  1092. tall[i++] = ed_anchor;
  1093. var cVisible = L.featureGroup( tall );
  1094. map_ed.flyToBounds( cVisible.getBounds() );
  1095. } else {
  1096. map_ed.setView([SiteLat, SiteLon], 4 );
  1097. };
  1098. },
  1099. failure: function( response, opts ) {
  1100. //var tPanel = Ext.getCmp('main_portal');
  1101. //tPanel.remove(0);
  1102. //tPanel.add( { html: 'Failed to load dashboard!' } );
  1103. //tPanel.doLayout();
  1104. }
  1105. });
  1106. };
  1107. var orientationEditorWindow = null;
  1108. var cubeViewport = null;
  1109. var cube = null;
  1110. var curX = 0;
  1111. var curY = 0;
  1112. var curZ = 0;
  1113. var bk_upd = false;
  1114. function setCubeOrientation( A, B, C ){
  1115. if( bk_upd ) return;
  1116. bk_upd = true;
  1117. curX = A;
  1118. curY = B;
  1119. curZ = C;
  1120. var t = Ext.getCmp('roll_sld');
  1121. t.setValue( A );
  1122. t = Ext.getCmp('roll');
  1123. t.setValue( A );
  1124. t = Ext.getCmp('pitch_sld');
  1125. t.setValue( B );
  1126. t = Ext.getCmp('pitch');
  1127. t.setValue( B );
  1128. t = Ext.getCmp('yaw_sld');
  1129. t.setValue( C );
  1130. t = Ext.getCmp('yaw');
  1131. t.setValue( C );
  1132. if( cube != null ) cube.set( curX, curY, curZ );
  1133. bk_upd = false;
  1134. };
  1135. function orientationEditor(){
  1136. if( orientationEditorWindow == null ){
  1137. orientationEditorWindow = new Ext.Window({
  1138. modal: true,
  1139. title: '<?=$Labels->GetLabel('_ORIENTATION_');?>',
  1140. closeAction: 'hide',
  1141. width: 640,
  1142. height: 500,
  1143. items:[{
  1144. layout: 'table',
  1145. defaults: {
  1146. bodyStyle:'padding:5px'
  1147. },
  1148. layoutConfig: {
  1149. columns: 3
  1150. },
  1151. items:[{
  1152. html: 'Roll:'
  1153. },{
  1154. xtype: 'textfield',
  1155. id: 'roll',
  1156. name: 'roll',
  1157. value: 30.0029,
  1158. listeners:{
  1159. change: function( sl, nv, tt ){
  1160. setCubeOrientation( nv / 1.0, curY, curZ );
  1161. }
  1162. }
  1163. },{
  1164. xtype: 'slider',
  1165. id: 'roll_sld',
  1166. width: 200,
  1167. value: 30.0029,
  1168. minValue: -180.0,
  1169. maxValue: 180.0,
  1170. listeners:{
  1171. change: function( sl, nv, tt ){
  1172. setCubeOrientation( nv, curY, curZ );
  1173. }
  1174. }
  1175. },{
  1176. html: 'Pitch:'
  1177. },{
  1178. xtype: 'textfield',
  1179. id: 'pitch',
  1180. name: 'pitch',
  1181. value: 30.0029,
  1182. listeners:{
  1183. change: function( sl, nv, tt ){
  1184. setCubeOrientation( curX, nv / 1.0, curZ );
  1185. }
  1186. }
  1187. },{
  1188. xtype: 'slider',
  1189. id: 'pitch_sld',
  1190. width: 200,
  1191. value: 30.0029,
  1192. minValue: -180.0,
  1193. maxValue: 180.0,
  1194. listeners:{
  1195. change: function( sl, nv, tt ){
  1196. setCubeOrientation( curX, nv, curZ );
  1197. }
  1198. }
  1199. },{
  1200. html: 'Yaw:'
  1201. },{
  1202. xtype: 'textfield',
  1203. id: 'yaw',
  1204. name: 'yaw',
  1205. value: 30.0029,
  1206. listeners:{
  1207. change: function( sl, nv, tt ){
  1208. //alert( nv );
  1209. setCubeOrientation( curX, curY, nv / 1.0 );
  1210. }
  1211. }
  1212. },{
  1213. xtype: 'slider',
  1214. id: 'yaw_sld',
  1215. width: 200,
  1216. value: 30.0029,
  1217. minValue: -180.0,
  1218. maxValue: 180.0,
  1219. listeners:{
  1220. change: function( sl, nv, tt ){
  1221. setCubeOrientation( curX, curY, nv );
  1222. }
  1223. }
  1224. }]
  1225. },{
  1226. html: '<div id="wrapper"><div class="viewport"><div class="cube"><div class="side"><div class="cube-image top">FRONT</div></div><div class="side"><div class="cube-image">TOP</div></div><div class="side"><div class="cube-image">RIGHT</div></div><div class="side"><div class="cube-image">BOTTOM</div></div><div class="side"><div class="cube-image">LEFT</div></div><div class="side"><div class="cube-image active">BACK</div></div></div></div></div>'
  1227. }],
  1228. buttons:[{
  1229. text: 'Cancel',
  1230. width: 200,
  1231. handler: function(){
  1232. orientationEditorWindow.hide();
  1233. }
  1234. },{
  1235. text: 'Apply',
  1236. width: 200,
  1237. handler: function(){
  1238. Ext.getCmp('sroll').setValue( Ext.getCmp('roll').getValue() );
  1239. Ext.getCmp('spitch').setValue( Ext.getCmp('pitch').getValue() );
  1240. Ext.getCmp('syaw').setValue( Ext.getCmp('yaw').getValue() );
  1241. orientationEditorWindow.hide();
  1242. }
  1243. }]
  1244. });
  1245. orientationEditorWindow.show();
  1246. cubeViewport = new Viewport({
  1247. element: document.getElementsByClassName('cube')[0],
  1248. fps: 20,
  1249. sensivity: .1,
  1250. sensivityFade: .93,
  1251. speed: 2,
  1252. touchSensivity: 1.5
  1253. });
  1254. cube = new Cube({
  1255. viewport: cubeViewport,
  1256. element: document.getElementsByClassName('cube')[0]
  1257. });
  1258. } else {
  1259. orientationEditorWindow.show();
  1260. };
  1261. setCubeOrientation( Ext.getCmp('sroll').getValue(), Ext.getCmp('spitch').getValue(), Ext.getCmp('syaw').getValue() );
  1262. };
  1263. var locationSelectedNode = 0;
  1264. function loadLoactionProps( e ){
  1265. if( typeof e == 'number' ){
  1266. locationSelectedNode = e;
  1267. } else {
  1268. locationSelectedNode = e.sourceTarget.options.mycustomid;
  1269. }
  1270. loadNodeLocationProps( locationSelectedNode );
  1271. };
  1272. function loadNodeLocationProps( NodeID ){
  1273. //alert( 'Node: ' + NodeID );
  1274. Ext.Ajax.request({
  1275. url: '/lib/controller/getLocationNodeProps.php',
  1276. params: {
  1277. NID: <?=$SiteID;?>,
  1278. UID: <?=$UserID;?>,
  1279. SID: '<?=$Session;?>',
  1280. NODE: NodeID
  1281. },
  1282. success: function( response, opts ){
  1283. // If the response is JSON, you have to decode it
  1284. var data = Ext.decode(response.responseText);
  1285. var tPanel = Ext.getCmp('prop_content');
  1286. tPanel.remove(0);
  1287. tPanel.add( data );
  1288. tPanel.doLayout();
  1289. },
  1290. failure: failureAJAXFunction
  1291. });
  1292. };
  1293. function LoadNodesList(){
  1294. Ext.Ajax.request({
  1295. url: '/lib/controller/getLocationNodes.php',
  1296. params: {
  1297. SITE: <?=$SiteID;?>,
  1298. UID: <?=$UserID;?>,
  1299. SID: '<?=$Session;?>'
  1300. },
  1301. success: function( response, opts ){
  1302. var data = Ext.decode(response.responseText);
  1303. var tPanel = Ext.getCmp('prop_content');
  1304. tPanel.remove(0);
  1305. tPanel.add( data );
  1306. tPanel.doLayout();
  1307. },
  1308. failure: failureAJAXFunction
  1309. });
  1310. };
  1311. function reloadSiteMapData(){
  1312. Ext.Ajax.request({
  1313. url: '/lib/controller/getMapData.php',
  1314. params: {
  1315. SITE: <?=$SiteID;?>,
  1316. UID: <?=$UserID;?>,
  1317. SID: '<?=$Session;?>'
  1318. },
  1319. success: function( response, opts ){
  1320. var data = Ext.decode(response.responseText);
  1321. MAP_ID = parseInt( data.selected_map );
  1322. MAP_IS_LOCAL = (MAP_ID)?data.local_binding:false;
  1323. MAP_SET = data.maps;
  1324. Ext.getCmp('lab_123').update( '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> '+((MAP_IS_LOCAL)?'Pos X':'<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>')+':' );
  1325. Ext.getCmp('lab_124').update( ((MAP_IS_LOCAL)?'Pos Y':'<?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>')+':' );
  1326. document.getElementById('lab_125').src = ((MAP_IS_LOCAL)?'/style/assets/map_mode_decart.png':'/style/assets/map_mode_wgs84.png');
  1327. loadLocationEditor('sys_location_map');
  1328. },
  1329. failure: failureAJAXFunction
  1330. });
  1331. };
  1332. var ed_anchor = null;
  1333. function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
  1334. if( tlInterval!= null ){
  1335. window.clearInterval( tlInterval );
  1336. tlInterval = null;
  1337. timelineObj = null;
  1338. };
  1339. if( node_type == undefined ) node_type = 0;
  1340. if( lat == undefined ){
  1341. lat = SiteLat;
  1342. lon = SiteLon;
  1343. };
  1344. //var cMSET = mapListStore.getAt( MAP_ID );
  1345. //alert( MAP_SET.id );
  1346. var aK = true;
  1347. if( MAP_SET.attribution == '' ) aK = false;
  1348. var mapLayers = [];
  1349. if( map_ed != undefined ){
  1350. map_ed.off();
  1351. map_ed.remove();
  1352. };
  1353. switch( MAP_SET.type ){
  1354. case 1:{
  1355. map_ed = L.map( el_id,{
  1356. attributionControl: aK,
  1357. //preferCanvas: true,
  1358. zoomControl: true,
  1359. center: [SiteLat,SiteLon],
  1360. /*zoomControl: false,
  1361. zoom: 17,
  1362. minZoom: 17,
  1363. maxZoom: 17,*/
  1364. keyboard: false
  1365. });
  1366. //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
  1367. // attribution: MAP_SET.attribution,
  1368. // maxNativeZoom: MAP_SET.maxNativeZoom,
  1369. // maxZoom: MAP_SET.maxZoom
  1370. //});
  1371. L.tileLayer( MAP_SET.layer_url, {
  1372. attribution: MAP_SET.attribution,
  1373. maxNativeZoom: MAP_SET.maxNativeZoom,
  1374. minZoom: 0,
  1375. maxZoom: MAP_SET.maxZoom
  1376. }).addTo( map_ed );
  1377. break;
  1378. };
  1379. case 2:{
  1380. map_ed = L.map( el_id,{
  1381. crs: L.CRS.Simple,
  1382. attributionControl: false,
  1383. preferCanvas: true,
  1384. zoomControl: true,
  1385. center: [SiteLat,SiteLon],
  1386. /*zoomControl: false,*/
  1387. zoom: 0,
  1388. minZoom: 0,
  1389. maxZoom: 4,
  1390. keyboard: false
  1391. });
  1392. var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
  1393. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map_ed );
  1394. break;
  1395. };
  1396. case 3:{
  1397. map_ed = L.map( el_id,{
  1398. attributionControl: false,
  1399. preferCanvas: true,
  1400. zoomControl: true,
  1401. center: [SiteLat,SiteLon],
  1402. zoom: MAP_SET.maxZoom - 2,
  1403. minZoom: MAP_SET.maxZoom - 4,
  1404. maxZoom: MAP_SET.maxZoom,
  1405. keyboard: false
  1406. });
  1407. var bounds = [[MAP_SET.bounds_ly,MAP_SET.bounds_lx], [MAP_SET.bounds_ry,MAP_SET.bounds_rx]];
  1408. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map_ed );
  1409. break;
  1410. };
  1411. };
  1412. map_ed.setView([SiteLat,SiteLon], MAP_SET.maxZoom );
  1413. if( node_type ){
  1414. ed_anchor = L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
  1415. } else {
  1416. ed_anchor = L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
  1417. };
  1418. /*
  1419. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1420. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1421. maxNativeZoom: 18,
  1422. maxZoom: 24,
  1423. })
  1424. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1425. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1426. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1427. maxZoom: 19
  1428. });
  1429. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1430. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1431. maxZoom: 19
  1432. });
  1433. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1434. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1435. maxZoom: 24
  1436. });
  1437. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1438. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1439. maxZoom: 19
  1440. });
  1441. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1442. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1443. maxZoom: 19
  1444. });
  1445. var baseMaps = {
  1446. "MyMap": mapLayers["MyMap"],
  1447. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1448. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1449. "EsriSat": mapLayers["EsriSat"],
  1450. "EsriStreet": mapLayers["EsriStreet"],
  1451. "EsriTopo": mapLayers["EsriTopo"],
  1452. //"Bing": mapLayers["Bing"],
  1453. //"OSM-Cycle": mapLayers["Cycle"],
  1454. //"Landscape": mapLayers["Landscape"],
  1455. //"Outdoor": mapLayers["Outdoor"],
  1456. };
  1457. L.control.layers( baseMaps ).addTo( map_ed );
  1458. mapLayers["MyMap"].addTo( map_ed );
  1459. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1460. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  1461. }).addTo( map_ed );
  1462. */
  1463. if( node_type ){
  1464. switch( node_type ){
  1465. case 1:{
  1466. markers[0] = L.marker([lat,lon], {draggable: true,icon: ALS_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1467. break;
  1468. };
  1469. case 2:{
  1470. markers[0] = L.marker([lat,lon], {draggable: true,icon: LFS_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1471. break;
  1472. };
  1473. case 3:{
  1474. markers[0] = L.marker([lat,lon], {draggable: true,icon: PLS200_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1475. break;
  1476. };
  1477. case 4:{
  1478. markers[0] = L.marker([lat,lon], {draggable: true,icon: PLS360_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1479. break;
  1480. };
  1481. case 5:{
  1482. markers[0] = L.marker([lat,lon], {draggable: true,icon: LRF3D_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1483. break;
  1484. };
  1485. case 6:{
  1486. markers[0] = L.marker([lat,lon], {draggable: true,icon: PLSNET200_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1487. break;
  1488. };
  1489. case 10:
  1490. case 12:{
  1491. markers[0] = L.marker([lat,lon], {draggable: true,icon: FIXCAM_Icon, mycustomid: node_id} ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1492. break;
  1493. };
  1494. case 11:
  1495. case 13:{
  1496. markers[0] = L.marker([lat,lon], {draggable: true,icon: PTZCAM_Icon, mycustomid: node_id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  1497. break;
  1498. };
  1499. };
  1500. } else loadLocationNodes();
  1501. };
  1502. function updateSiteAnchor(){
  1503. SiteLat = Ext.getCmp('siteLat').getValue();
  1504. SiteLon = Ext.getCmp('siteLon').getValue();
  1505. SiteAlt = Ext.getCmp('siteAlt').getValue();
  1506. Ext.Ajax.request({
  1507. url: '/lib/controller/updateLocation.php',
  1508. params: {
  1509. SITE: <?=$SiteID;?>,
  1510. UID: <?=$UserID;?>,
  1511. TYPE: 1,
  1512. SID: '<?=$Session;?>',
  1513. LAT: SiteLat,
  1514. LON: SiteLon,
  1515. ALT: SiteAlt
  1516. },
  1517. success: function(){
  1518. loadLocationEditor('sys_location_map');
  1519. },
  1520. failure: failureAJAXFunction
  1521. });
  1522. };
  1523. function updateSiteMap(){
  1524. MAP_ID = Ext.getCmp('siteMap').getValue();
  1525. Ext.Ajax.request({
  1526. url: '/lib/controller/updateLocation.php',
  1527. params: {
  1528. SITE: <?=$SiteID;?>,
  1529. UID: <?=$UserID;?>,
  1530. TYPE: 4,
  1531. SID: '<?=$Session;?>',
  1532. MID: MAP_ID
  1533. },
  1534. success: function( response, opts ){
  1535. reloadSiteMapData();
  1536. },
  1537. failure: failureAJAXFunction
  1538. });
  1539. };
  1540. var mapDataLoadded = false;
  1541. // Call this to prepare all data once in Session
  1542. function prepareMapData(){
  1543. //if( ap_type == 1 ) return;//Metro No Map ...
  1544. if( !mapDataLoadded ){
  1545. mapListStore.load();
  1546. };
  1547. };
  1548. function updateLocationOrientation(){
  1549. var tLat = Ext.getCmp('slat').getValue();
  1550. var tLon = Ext.getCmp('slon').getValue();
  1551. var tAlt = Ext.getCmp('salt').getValue();
  1552. var tRoll = Ext.getCmp('sroll').getValue();
  1553. var tPitch = Ext.getCmp('spitch').getValue();
  1554. var tYaw = Ext.getCmp('syaw').getValue();
  1555. Ext.Ajax.request({
  1556. url: '/lib/controller/updateLocation.php',
  1557. params: {
  1558. NODE: locationSelectedNode,
  1559. UID: <?=$UserID;?>,
  1560. TYPE: 2,
  1561. SID: '<?=$Session;?>',
  1562. LAT: tLat,
  1563. LON: tLon,
  1564. ALT: tAlt,
  1565. YAW: tYaw,
  1566. ROLL: tRoll,
  1567. PITCH: tPitch
  1568. },
  1569. failure: failureAJAXFunction
  1570. });
  1571. };
  1572. var iconSaver = null;
  1573. var markerSaver = null;
  1574. function updateLocation( e ){
  1575. locationSelectedNode = e.target.options.mycustomid;
  1576. Ext.Ajax.request({
  1577. url: '/lib/controller/updateLocation.php',
  1578. params: {
  1579. NODE: locationSelectedNode,
  1580. SITE: <?=$SiteID;?>,
  1581. UID: <?=$UserID;?>,
  1582. TYPE: 0,
  1583. SID: '<?=$Session;?>',
  1584. LAT: e.target._latlng.lat,
  1585. LON: e.target._latlng.lng
  1586. },
  1587. success: function( response, opts ){
  1588. loadNodeLocationProps( locationSelectedNode );
  1589. },
  1590. failure: failureAJAXFunction
  1591. });
  1592. };
  1593. function markerDblClick( e ){
  1594. if( iconSaver == null ){
  1595. iconSaver = e.target.options.icon;
  1596. markerSaver = e.target;
  1597. e.target.setIcon( SNAPE_Icon );
  1598. for( i=0; i< markers.length; i++){
  1599. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  1600. markers[i].setOpacity( 0.1 );
  1601. } else {
  1602. markers[i].setOpacity( 1.0 );
  1603. }
  1604. };
  1605. } else {
  1606. if( e.target.options.mycustomid == markerSaver.options.mycustomid ){
  1607. e.target.setIcon( iconSaver );
  1608. iconSaver = null;
  1609. markerSaver = null;
  1610. for( i=0; i< markers.length; i++){
  1611. markers[i].setOpacity( 1.0 );
  1612. };
  1613. } else {
  1614. markerSaver.setIcon( iconSaver );
  1615. iconSaver = e.target.options.icon;
  1616. markerSaver = e.target;
  1617. e.target.setIcon( SNAPE_Icon );
  1618. for( i=0; i< markers.length; i++){
  1619. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  1620. markers[i].setOpacity( 0.1 );
  1621. } else {
  1622. markers[i].setOpacity( 1.0 );
  1623. }
  1624. };
  1625. };
  1626. };
  1627. };
  1628. /*
  1629. function setNodeLocationToAnchor(){
  1630. Ext.Ajax.request({
  1631. url: '/lib/controller/updateLocation.php',
  1632. params: {
  1633. NODE: locationSelectedNode,
  1634. SITE: <?=$SiteID;?>,
  1635. UID: <?=$UserID;?>,
  1636. TYPE: 0,
  1637. SID: '<?=$Session;?>',
  1638. LAT: SiteLat,
  1639. LON: SiteLon,
  1640. ALT: SiteAlt
  1641. },
  1642. success: function( response, opts ){
  1643. loadLocationEditor('sys_location_map');
  1644. },
  1645. failure: failureAJAXFunction
  1646. });
  1647. };
  1648. function setNodeLocationByDelta(){
  1649. var dx = Ext.getCmp('dx').getValue();
  1650. var dy = Ext.getCmp('dy').getValue();
  1651. var dz = Ext.getCmp('dz').getValue();
  1652. Ext.Ajax.request({
  1653. url: '/lib/controller/updateLocation.php',
  1654. params: {
  1655. NODE: locationSelectedNode,
  1656. SITE: <?=$SiteID;?>,
  1657. UID: <?=$UserID;?>,
  1658. TYPE: 3,
  1659. SID: '<?=$Session;?>',
  1660. LAT: dx,
  1661. LON: dy,
  1662. ALT: dz
  1663. },
  1664. success: function( response, opts ){
  1665. loadLocationEditor();
  1666. },
  1667. failure: failureAJAXFunction
  1668. });
  1669. };
  1670. */
  1671. var mapCreatorWindow = null;
  1672. function createNewMap(){
  1673. if( mapCreatorWindow == null ){
  1674. mapCreatorWindow = new Ext.Window({
  1675. width: 800,
  1676. height: 580,
  1677. title: "<?=$Labels->GetLabel('_CREATE_CUSTOM_MAP_');?>",
  1678. modal: true,
  1679. frame: true,
  1680. border: false,
  1681. resizable: false,
  1682. items: [{
  1683. xtype: 'tabpanel',
  1684. id: 'mcr_tbp',
  1685. activeTab: 0,
  1686. items:[{
  1687. xtype: 'form',
  1688. title: "<?=$Labels->GetLabel('_INTER_MAP_');?>",
  1689. id: 'map_map_frm',
  1690. fileUpload: true,
  1691. labelWidth: 250,
  1692. labelAlign: 'right',
  1693. height: 490,
  1694. items:[{
  1695. xtype: 'textfield',
  1696. fieldLabel: "<?=$Labels->GetLabel('_NAME_MAP_');?>",
  1697. name: 'map_name',
  1698. width: 540,
  1699. },{
  1700. xtype: 'hidden',
  1701. name: 'ctype',
  1702. value: 1
  1703. },{
  1704. xtype: 'textfield',
  1705. fieldLabel: "<?=$Labels->GetLabel('_TILE_URL_MAP_');?>",
  1706. name: 'map_url',
  1707. width: 540,
  1708. },{
  1709. xtype: 'textfield',
  1710. fieldLabel: "<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>",
  1711. name: 'map_attr',
  1712. width: 540,
  1713. },{
  1714. xtype: 'textarea',
  1715. fieldLabel: "<?=$Labels->GetLabel('_DESCRIPTION_');?>",
  1716. name: 'map_desc',
  1717. width: 540,
  1718. },{
  1719. xtype: 'combo',
  1720. fieldLabel: "<?=$Labels->GetLabel('_MAX_ZOOM_');?>",
  1721. name: 'map_maxz',
  1722. editable: false,
  1723. typeAhead: true,
  1724. triggerAction: 'all',
  1725. width: 100,
  1726. lazyRender:true,
  1727. mode: 'local',
  1728. store: new Ext.data.ArrayStore({
  1729. fields: ['zoom_l'],
  1730. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1731. }),
  1732. value: '18',
  1733. valueField: 'zoom_l',
  1734. displayField: 'zoom_l'
  1735. },{
  1736. xtype: 'combo',
  1737. fieldLabel: "<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>",
  1738. name: 'map_maxnz',
  1739. editable: false,
  1740. typeAhead: true,
  1741. triggerAction: 'all',
  1742. width: 100,
  1743. lazyRender:true,
  1744. mode: 'local',
  1745. store: new Ext.data.ArrayStore({
  1746. fields: ['zoom_l'],
  1747. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1748. }),
  1749. value: '16',
  1750. valueField: 'zoom_l',
  1751. displayField: 'zoom_l'
  1752. }]
  1753. },{
  1754. xtype: 'form',
  1755. title: "<?=$Labels->GetLabel('_LOCAL_PIC_MAP_');?>",
  1756. id: 'map_pic_frm',
  1757. fileUpload: true,
  1758. height: 490,
  1759. //autoHeight: true,
  1760. //bodyStyle: 'padding: 10px 10px 0 10px;',
  1761. labelWidth: 250,
  1762. labelAlign: 'right',
  1763. defaults: {
  1764. //anchor: '95%',
  1765. //allowBlank: false,
  1766. msgTarget: 'side'
  1767. },
  1768. items: [{
  1769. xtype: 'textfield',
  1770. fieldLabel: "<?=$Labels->GetLabel('_MAP_NAME_');?>",
  1771. id: 'map_name_2',
  1772. name: 'map_name',
  1773. width: 540
  1774. },{
  1775. xtype: 'hidden',
  1776. name: 'ctype',
  1777. value: 2
  1778. },{
  1779. xtype: 'fileuploadfield',
  1780. id: 'form-file',
  1781. emptyText: "<?=$Labels->GetLabel('_SELE_ANIMAGE_');?>",
  1782. fieldLabel: "<?=$Labels->GetLabel('_MAP_PICTURE_');?>",
  1783. width: 500,
  1784. name: 'map_image',
  1785. buttonText: "<?=$Labels->GetLabel('_BROWSE_');?>"
  1786. },{
  1787. xtype: 'textfield',
  1788. fieldLabel: "<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>",
  1789. name: 'map_attr',
  1790. width: 540,
  1791. },{
  1792. xtype: 'textarea',
  1793. fieldLabel: "<?=$Labels->GetLabel('_DESCRIPTION_');?>",
  1794. name: 'map_desc',
  1795. width: 540,
  1796. },{
  1797. xtype: 'combo',
  1798. fieldLabel: "<?=$Labels->GetLabel('_MAX_ZOOM_');?>",
  1799. editable: false,
  1800. typeAhead: true,
  1801. id: 'map_maxz',
  1802. name: 'map_maxz',
  1803. triggerAction: 'all',
  1804. width: 100,
  1805. lazyRender:true,
  1806. mode: 'local',
  1807. store: new Ext.data.ArrayStore({
  1808. fields: ['zoom_l'],
  1809. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1810. }),
  1811. value: '4',
  1812. valueField: 'zoom_l',
  1813. displayField: 'zoom_l'
  1814. },{
  1815. xtype: 'combo',
  1816. fieldLabel: "<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>",
  1817. editable: false,
  1818. typeAhead: true,
  1819. id: 'map_maxnz',
  1820. name: 'map_maxnz',
  1821. triggerAction: 'all',
  1822. width: 100,
  1823. lazyRender:true,
  1824. mode: 'local',
  1825. store: new Ext.data.ArrayStore({
  1826. fields: ['zoom_l'],
  1827. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1828. }),
  1829. value: '4',
  1830. valueField: 'zoom_l',
  1831. displayField: 'zoom_l'
  1832. },{
  1833. xtype: 'numberfield',
  1834. fieldLabel: "<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>",
  1835. name: 'map_tpb',
  1836. value: 0,
  1837. width: 540,
  1838. },{
  1839. xtype: 'numberfield',
  1840. fieldLabel: "<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>",
  1841. name: 'map_lpb',
  1842. value: 0,
  1843. width: 540,
  1844. },{
  1845. xtype: 'numberfield',
  1846. fieldLabel: "<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>",
  1847. name: 'map_rpb',
  1848. value: 0,
  1849. width: 540,
  1850. },{
  1851. xtype: 'numberfield',
  1852. fieldLabel: "<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>",
  1853. name: 'map_bpb',
  1854. value: 0,
  1855. width: 540,
  1856. },{
  1857. xtype: 'combo',
  1858. fieldLabel: "<?=$Labels->GetLabel('_MAP_COORD_SYSTEM_');?>",
  1859. editable: false,
  1860. typeAhead: true,
  1861. hiddenName: 'map_corsys',
  1862. triggerAction: 'all',
  1863. width: 540,
  1864. lazyRender:true,
  1865. mode: 'local',
  1866. store: new Ext.data.ArrayStore({
  1867. fields: ['C_SYS_V','C_SYS'],
  1868. data: [[0,'Meters from map Centre'], [1,'WGS84(GPS)']]
  1869. }),
  1870. listeners:{
  1871. select: function( a, b, c ){
  1872. if( c ){
  1873. Ext.getCmp('map_height').hide();
  1874. Ext.getCmp('map_maxz').hide();
  1875. Ext.getCmp('map_maxnz').hide();
  1876. Ext.getCmp('map_width').hide();
  1877. Ext.getCmp('map_cpp').hide();
  1878. Ext.getCmp('map_cpb').show();
  1879. } else {
  1880. Ext.getCmp('map_height').show();
  1881. Ext.getCmp('map_maxz').show();
  1882. Ext.getCmp('map_maxnz').show();
  1883. Ext.getCmp('map_width').show();
  1884. Ext.getCmp('map_cpp').show();
  1885. Ext.getCmp('map_cpb').hide();
  1886. };
  1887. }
  1888. },
  1889. value: '0',
  1890. valueField: 'C_SYS_V',
  1891. displayField: 'C_SYS'
  1892. },{
  1893. xtype: 'numberfield',
  1894. fieldLabel: "<?=$Labels->GetLabel('_MAP_WIDTH_');?>",
  1895. id: 'map_height',
  1896. name: 'map_height',
  1897. decimalPrecision: 2,
  1898. value: 1000.00,
  1899. width: 540,
  1900. },{
  1901. xtype: 'numberfield',
  1902. fieldLabel: "<?=$Labels->GetLabel('_MAP_HEIGHT_');?>",
  1903. id: 'map_width',
  1904. name: 'map_width',
  1905. decimalPrecision: 2,
  1906. value: 1000.00,
  1907. width: 540,
  1908. },{
  1909. xtype: 'panel',
  1910. id: 'map_cpp',
  1911. frame: false,
  1912. border: false,
  1913. layout: 'table',
  1914. layoutConfig: {
  1915. columns: 5
  1916. },
  1917. items:[{
  1918. xtype: 'spacer',
  1919. width: 250,
  1920. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_MAP_CENTER_MODE_');?>:</p>"
  1921. },{
  1922. xtype: 'radio',
  1923. name: 'bounds_mode',
  1924. inputValue: 0,
  1925. checked: 1
  1926. },{
  1927. width: 80,
  1928. html: '<img src="/style/assets/cust_map_cord_sys-0.png">'
  1929. },{
  1930. xtype: 'radio',
  1931. name: 'bounds_mode',
  1932. checked: 0,
  1933. inputValue: 1
  1934. },{
  1935. html: '<img src="/style/assets/cust_map_cord_sys-1.png">'
  1936. }]
  1937. },{
  1938. xtype: 'panel',
  1939. id: 'map_cpb',
  1940. frame: false,
  1941. border: false,
  1942. hidden: true,
  1943. layout: 'table',
  1944. layoutConfig: {
  1945. columns: 5
  1946. },
  1947. items:[{
  1948. xtype: 'spacer',
  1949. width: 250,
  1950. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_MAP_LEFT_CORCORD_');?>:</p>"
  1951. },{
  1952. xtype: 'spacer',
  1953. width: 100,
  1954. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_LAT_');?></p>"
  1955. },{
  1956. xtype: 'numberfield',
  1957. id: 'map_lcclat',
  1958. name: 'map_lcclat',
  1959. decimalPrecision: 8,
  1960. value: 32.0001,
  1961. width: 150,
  1962. },{
  1963. xtype: 'spacer',
  1964. width: 100,
  1965. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_LON_');?></p>"
  1966. },{
  1967. xtype: 'numberfield',
  1968. id: 'map_lcclon',
  1969. name: 'map_lcclon',
  1970. decimalPrecision: 8,
  1971. value: 32.0001,
  1972. width: 150,
  1973. },{
  1974. xtype: 'spacer',
  1975. width: 250,
  1976. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_MAP_RIGHT_CORCORD_');?>:</p>"
  1977. },{
  1978. xtype: 'spacer',
  1979. width: 100,
  1980. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_LAT_');?></p>"
  1981. },{
  1982. xtype: 'numberfield',
  1983. id: 'map_rcclat',
  1984. name: 'map_rcclat',
  1985. decimalPrecision: 8,
  1986. value: 32.0001,
  1987. width: 150,
  1988. },{
  1989. xtype: 'spacer',
  1990. width: 100,
  1991. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_LON_');?></p>"
  1992. },{
  1993. xtype: 'numberfield',
  1994. id: 'map_rcclon',
  1995. name: 'map_rcclon',
  1996. decimalPrecision: 8,
  1997. value: 32.0001,
  1998. width: 150,
  1999. }]
  2000. }]
  2001. }]
  2002. }],
  2003. bbar:[ '->',{
  2004. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  2005. handler: function(){
  2006. //Ext.getCmp('map_map_frm').getForm().reset();
  2007. //Ext.getCmp('map_pic_frm').getForm().reset();
  2008. mapCreatorWindow.destroy();
  2009. }
  2010. },{
  2011. text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>',
  2012. handler: function(){
  2013. var tt = Ext.getCmp('mcr_tbp').getActiveTab();
  2014. if( tt.id == 'map_map_frm' ){
  2015. if( Ext.getCmp('map_map_frm').getForm().isValid()){
  2016. Ext.getCmp('map_map_frm').getForm().submit({
  2017. url: '/lib/controller/addMap.php',
  2018. waitMsg: 'Uploading Data...',
  2019. encoding: 'multipart/form-data',
  2020. success: function(fp, o){
  2021. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  2022. //alert('Processed file on the server');
  2023. mapCreatorWindow.destroy();
  2024. }
  2025. });
  2026. };
  2027. } else {
  2028. if( Ext.getCmp('map_pic_frm').getForm().isValid()){
  2029. Ext.getCmp('map_pic_frm').getForm().submit({
  2030. url: '/lib/controller/addMap.php',
  2031. waitMsg: 'Uploading Image...',
  2032. encoding: 'multipart/form-data',
  2033. success: function(fp, o){
  2034. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  2035. //alert('Processed file on the server');
  2036. mapCreatorWindow.destroy();
  2037. }
  2038. });
  2039. };
  2040. };
  2041. }
  2042. }],
  2043. listeners:{
  2044. beforedestroy: function(){
  2045. mapCreatorWindow = null;
  2046. }
  2047. }
  2048. });
  2049. };
  2050. mapCreatorWindow.show();
  2051. };
  2052. var mapEditorWindow = null;
  2053. function deleteCurrentMap(){
  2054. Ext.Ajax.request({
  2055. url: '/lib/controller/delMapData.php',
  2056. params: {
  2057. SITE: <?=$SiteID;?>,
  2058. UID: <?=$UserID;?>,
  2059. SID: '<?=$Session;?>',
  2060. MID: MAP_ID
  2061. },
  2062. success: function( response, opts ){
  2063. location.reload();
  2064. }
  2065. });
  2066. };
  2067. function editCurrentMap(){
  2068. Ext.Ajax.request({
  2069. url: '/lib/controller/getMapData.php',
  2070. params: {
  2071. SITE: <?=$SiteID;?>,
  2072. UID: <?=$UserID;?>,
  2073. SID: '<?=$Session;?>',
  2074. MID: MAP_ID
  2075. },
  2076. success: function( response, opts ){
  2077. var newMapData = Ext.decode( response.responseText );
  2078. if( mapEditorWindow == null ){
  2079. switch( newMapData.type ){
  2080. case 1:{
  2081. mapEditorWindow = new Ext.Window({
  2082. width: 800,
  2083. height: 440,
  2084. title: 'Edit Current Map',
  2085. modal: true,
  2086. //closeAction: 'hide',
  2087. frame: true,
  2088. border: false,
  2089. resizable: false,
  2090. items: [{
  2091. xtype: 'form',
  2092. id: 'map_map_frm',
  2093. labelWidth: 250,
  2094. labelAlign: 'right',
  2095. height: 350,
  2096. items:[{
  2097. xtype: 'textfield',
  2098. fieldLabel: 'Map Name',
  2099. id: 'map_name_1',
  2100. name: 'map_name',
  2101. width: 540,
  2102. },{
  2103. xtype: 'hidden',
  2104. name: 'ctype',
  2105. value: 1
  2106. },{
  2107. xtype: 'textfield',
  2108. fieldLabel: 'Tiles URL Pattern',
  2109. name: 'map_url',
  2110. width: 540,
  2111. },{
  2112. xtype: 'textfield',
  2113. fieldLabel: 'Layer Attribution',
  2114. name: 'map_attr',
  2115. width: 540,
  2116. },{
  2117. xtype: 'textarea',
  2118. fieldLabel: 'Description',
  2119. name: 'map_desc',
  2120. width: 540,
  2121. },{
  2122. xtype: 'combo',
  2123. fieldLabel: 'Max Zoom',
  2124. name: 'map_maxz',
  2125. editable: false,
  2126. typeAhead: true,
  2127. triggerAction: 'all',
  2128. width: 100,
  2129. lazyRender:true,
  2130. mode: 'local',
  2131. store: new Ext.data.ArrayStore({
  2132. fields: ['zoom_l'],
  2133. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  2134. }),
  2135. value: '18',
  2136. valueField: 'zoom_l',
  2137. displayField: 'zoom_l'
  2138. },{
  2139. xtype: 'combo',
  2140. fieldLabel: 'Max Native Zoom',
  2141. name: 'map_maxnz',
  2142. editable: false,
  2143. typeAhead: true,
  2144. triggerAction: 'all',
  2145. width: 100,
  2146. lazyRender:true,
  2147. mode: 'local',
  2148. store: new Ext.data.ArrayStore({
  2149. fields: ['zoom_l'],
  2150. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  2151. }),
  2152. value: '16',
  2153. valueField: 'zoom_l',
  2154. displayField: 'zoom_l'
  2155. }]
  2156. }],
  2157. bbar:[ '->',{
  2158. text: "<?=$Labels->GetLabel('_CANCEL_');?>",
  2159. handler: function(){
  2160. mapEditorWindow.destroy();
  2161. }
  2162. },{
  2163. text: "<?=$Labels->GetLabel('_APPLY_CHANGES_');?>",
  2164. handler: function(){
  2165. var tt = Ext.getCmp('mcr_tbp').getActiveTab();
  2166. if( tt.id == 'map_map_frm' ){
  2167. if( Ext.getCmp('map_map_frm').getForm().isValid()){
  2168. Ext.getCmp('map_map_frm').getForm().submit({
  2169. url: '/lib/controller/updateMap.php',
  2170. waitMsg: "<?=$Labels->GetLabel('_UPDATING_DATA_');?>...",
  2171. clientValidation: false,
  2172. encoding: 'multipart/form-data',
  2173. success: function(f,a){
  2174. alert('Processed file on the server1');
  2175. //mapEditorWindow.hide();
  2176. //mapEditorWindow.destroy();
  2177. }
  2178. });
  2179. };
  2180. } else {
  2181. if( Ext.getCmp('map_pic_frm').getForm().isValid()){
  2182. Ext.getCmp('map_pic_frm').getForm().submit({
  2183. url: '/lib/controller/updateMap.php',
  2184. clientValidation: false,
  2185. waitMsg: "<?=$Labels->GetLabel('_UPDATING_DATA_');?>...",
  2186. encoding: 'multipart/form-data',
  2187. success: function( f, a ){
  2188. alert('Processed file on the server2');
  2189. //mapEditorWindow.hide();
  2190. //mapEditorWindow.destroy();
  2191. }
  2192. });
  2193. };
  2194. };
  2195. }
  2196. }],
  2197. listeners: {
  2198. beforedestroy: function(){
  2199. mapEditorWindow = null;
  2200. }
  2201. }
  2202. });
  2203. break;
  2204. };
  2205. default:{
  2206. mapEditorWindow = new Ext.Window({
  2207. width: 800,
  2208. height: 540,
  2209. title: "<?=$Labels->GetLabel('_EDIT_CUR_MAP_');?>",
  2210. modal: true,
  2211. frame: true,
  2212. border: false,
  2213. resizable: false,
  2214. items: [{
  2215. xtype: 'form',
  2216. id: 'map_edt_frm',
  2217. height: 480,
  2218. //autoHeight: true,
  2219. //bodyStyle: 'padding: 10px 10px 0 10px;',
  2220. labelWidth: 250,
  2221. labelAlign: 'right',
  2222. defaults: {
  2223. //anchor: '95%',
  2224. //allowBlank: false,
  2225. msgTarget: 'side'
  2226. },
  2227. items:[{
  2228. xtype: 'spacer',
  2229. height: 6
  2230. },{
  2231. xtype: 'textfield',
  2232. fieldLabel: "<?=$Labels->GetLabel('_MAP_NAME_');?>",
  2233. name: 'map_name',
  2234. value: newMapData.name,
  2235. width: 540
  2236. },{
  2237. xtype: 'hidden',
  2238. name: 'MID',
  2239. value: newMapData.id
  2240. },{
  2241. xtype: 'panel',
  2242. frame: false,
  2243. border: false,
  2244. html: '<center><img height="50px" SRC="/lib/controller/data/assets/images/'+MAP_SET.layer_url+'"></center>'
  2245. },{
  2246. xtype: 'textfield',
  2247. fieldLabel: "<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>",
  2248. name: 'map_attr',
  2249. value: newMapData.attribution,
  2250. width: 540,
  2251. },{
  2252. xtype: 'textarea',
  2253. fieldLabel: "<?=$Labels->GetLabel('_DESCRIPTION_');?>",
  2254. name: 'map_desc',
  2255. value: newMapData.desc,
  2256. width: 540,
  2257. },{
  2258. xtype: 'combo',
  2259. fieldLabel: "<?=$Labels->GetLabel('_MAX_ZOOM_');?>",
  2260. editable: false,
  2261. typeAhead: true,
  2262. name: 'map_maxz',
  2263. value: newMapData.maxZoom,
  2264. triggerAction: 'all',
  2265. width: 100,
  2266. lazyRender:true,
  2267. mode: 'local',
  2268. store: new Ext.data.ArrayStore({
  2269. fields: ['zoom_l'],
  2270. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  2271. }),
  2272. value: '16',
  2273. valueField: 'zoom_l',
  2274. displayField: 'zoom_l'
  2275. },{
  2276. xtype: 'combo',
  2277. fieldLabel: "<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>",
  2278. editable: false,
  2279. typeAhead: true,
  2280. name: 'map_maxnz',
  2281. value: newMapData.maxNativeZoom,
  2282. triggerAction: 'all',
  2283. width: 100,
  2284. lazyRender:true,
  2285. mode: 'local',
  2286. store: new Ext.data.ArrayStore({
  2287. fields: ['zoom_l'],
  2288. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  2289. }),
  2290. value: '16',
  2291. valueField: 'zoom_l',
  2292. displayField: 'zoom_l'
  2293. },{
  2294. xtype: 'numberfield',
  2295. fieldLabel: "<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>",
  2296. name: 'map_tpb',
  2297. value: newMapData.img_tb,
  2298. width: 540,
  2299. },{
  2300. xtype: 'numberfield',
  2301. fieldLabel: "<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>",
  2302. name: 'map_lpb',
  2303. value: newMapData.img_lb,
  2304. width: 540,
  2305. },{
  2306. xtype: 'numberfield',
  2307. fieldLabel: "<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>",
  2308. name: 'map_rpb',
  2309. value: newMapData.img_rb,
  2310. width: 540,
  2311. },{
  2312. xtype: 'numberfield',
  2313. fieldLabel: "<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>",
  2314. name: 'map_bpb',
  2315. value: newMapData.img_bb,
  2316. width: 540,
  2317. },{
  2318. xtype: 'numberfield',
  2319. fieldLabel: "<?=$Labels->GetLabel('_MAP_WIDTH_');?>",
  2320. name: 'map_width',
  2321. decimalPrecision: 2,
  2322. value: newMapData.img_map_w,
  2323. width: 540,
  2324. },{
  2325. xtype: 'numberfield',
  2326. fieldLabel: "<?=$Labels->GetLabel('_MAP_HEIGHT_');?>",
  2327. name: 'map_height',
  2328. decimalPrecision: 2,
  2329. value: newMapData.img_map_h,
  2330. width: 540,
  2331. },{
  2332. xtype: 'panel',
  2333. frame: false,
  2334. border: false,
  2335. layout: 'table',
  2336. layoutConfig: {
  2337. columns: 5
  2338. },
  2339. items:[{
  2340. xtype: 'spacer',
  2341. width: 250,
  2342. html: "<p style='text-align:right; margin-right: 5px;'><?=$Labels->GetLabel('_MAP_CENTER_MODE_');?>:</p>"
  2343. },{
  2344. xtype: 'radio',
  2345. name: 'bounds_mode',
  2346. inputValue: 0,
  2347. checked: (newMapData.bounds_mode == 0)
  2348. },{
  2349. width: 80,
  2350. border: false,
  2351. html: '<img src="/style/assets/cust_map_cord_sys-0.png">'
  2352. },{
  2353. xtype: 'radio',
  2354. name: 'bounds_mode',
  2355. inputValue: 1,
  2356. checked: (newMapData.bounds_mode != 0)
  2357. },{
  2358. html: '<img src="/style/assets/cust_map_cord_sys-1.png">'
  2359. }]
  2360. }]
  2361. }],
  2362. bbar:[ '->',{
  2363. text: "<?=$Labels->GetLabel('_CANCEL_');?>",
  2364. handler: function(){
  2365. mapEditorWindow.destroy();
  2366. }
  2367. },{
  2368. text: '<?=$Labels->GetLabel('_APPLY_CHANGES_');?>',
  2369. handler: function(){
  2370. if( Ext.getCmp('map_edt_frm').getForm().isValid()){
  2371. Ext.getCmp('map_edt_frm').getForm().submit({
  2372. url: '/lib/controller/updateMap.php',
  2373. waitMsg: "<?=$Labels->GetLabel('_UPDATING_DATA_');?>...",
  2374. encoding: 'multipart/form-data',
  2375. success: function(fp, o){
  2376. mapEditorWindow.destroy();
  2377. }
  2378. });
  2379. };
  2380. }
  2381. }],
  2382. listeners: {
  2383. beforedestroy: function(){
  2384. mapEditorWindow = null;
  2385. }
  2386. }
  2387. });
  2388. break;
  2389. };
  2390. };
  2391. };
  2392. mapEditorWindow.show();
  2393. },
  2394. failure: failureAJAXFunction
  2395. });
  2396. };