Web Interface For Lite Argus Control modules
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.

2567 lines
80 KiB

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