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.

1813 lines
59 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
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. map.flyToBounds( cVisible.getBounds() );
  77. };
  78. function loadMapZones( SID ){
  79. Ext.Ajax.request({
  80. url: '/lib/controller/getGeoZones.php',
  81. params: {
  82. SITE: SID,
  83. UID: <?=$UserID;?>,
  84. SID: '<?=$Session;?>'
  85. },
  86. success: function( response, opts ){
  87. // If the response is JSON, you have to decode it
  88. var data = Ext.decode(response.responseText);
  89. var pp = Ext.getCmp('sources_panel');
  90. if( typeof pp !== 'undefined' ) pp.removeAll();
  91. ActiveZones = data;
  92. ActiveZones.fig = new Array();
  93. ActiveZones.zang = new Array();
  94. ActiveZones.center = new Array();
  95. for(var i = 0; i < data.totalCount; i++ ) {
  96. switch( data.zones[i].type ){
  97. case 'circle':{
  98. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  99. 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 } );
  100. //map.addLayer( ActiveZones.fig[i] );
  101. break;
  102. };
  103. case 'poly':{
  104. 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);
  105. //map.addLayer( ActiveZones.fig[i] );
  106. break;
  107. };
  108. case 'image':{
  109. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  110. //map.addLayer( ActiveZones.fig[i] );
  111. break;
  112. };
  113. case 'image_rot':{
  114. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  115. opacity: 0.8 //,
  116. //interactive: true,
  117. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geogr?fico Nacional de Espa?a</a>"
  118. });//.addTo( map );
  119. //map.addLayer( ActiveZones.fig[i] );
  120. break;
  121. };
  122. };
  123. /*
  124. if( data.zones[i].dev_is_source ){
  125. if( typeof pp !== 'undefined' ) {
  126. var sty = '';
  127. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  128. sty = 'cardDeviceSourceSelected';
  129. } else {
  130. sty = 'cardDeviceSource';
  131. };
  132. pp.add( {
  133. id: data.zones[i].dev_id+'_container',
  134. frame: false,
  135. border: false,
  136. width: 130,
  137. height: 130,
  138. 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>'
  139. });
  140. };
  141. };*/
  142. if( data.zones[i].zang != undefined ){
  143. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  144. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  145. };
  146. if( data.zones[i].center != undefined ){
  147. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  148. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  149. };
  150. };
  151. //if( selecredActiveSourceFilter == 0 ){
  152. turnAllGzOn();
  153. //} else {
  154. // turnOffAllGzButThis( selecredActiveSourceFilter );
  155. //};
  156. //if( typeof pp !== 'undefined' ) pp.doLayout();
  157. },
  158. failure: function( response, opts ) {
  159. //Ext.fly('some_div').update('Fail!');
  160. }
  161. });
  162. };
  163. var cevt = Array();
  164. var coz = Array();
  165. function showEventsOnMap( data, removeCursor ){
  166. if( removeCursor == undefined ) removeCursor = true;
  167. if( removeCursor ) map.removeLayer( selectedMarker );
  168. if( cevt.length ){
  169. for( i=0; i< cevt.length; i++ ){
  170. if( cevt[i]!= null ){
  171. cevt[i].remove();
  172. delete( cevt[i] );
  173. cevt[i] = null;
  174. };
  175. };
  176. };
  177. if( coz.length ){
  178. for( i=0; i< coz.length; i++ ){
  179. if( coz[i]!= null ){
  180. coz[i].remove();
  181. delete( coz[i] );
  182. coz[i]=null;
  183. };
  184. };
  185. };
  186. var idx = 0;
  187. for( i=0; i < data.length; i++ ){
  188. if( data[i].targets != undefined ){
  189. var zz = ( 1.0 / ( data[i].targets.length + 0 ) );
  190. var cp_color='#FF0000';
  191. for( j = 0; j < data[i].targets.length; j++ ){
  192. //switch( data.log[i].event ){
  193. // case 36: cp_color='#0000FF'; break;
  194. //};
  195. cLon = data[i].targets[j].lat;
  196. cLat = data[i].targets[j].lon;
  197. 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 ){
  198. // loadEventPropertiesByID( this.options.id );
  199. //} );
  200. cevt[idx].addTo(map);
  201. idx++;
  202. };
  203. };
  204. };
  205. };
  206. function LoadMapEventsZ( Mode ){
  207. if( tlLoadLocker ) return;
  208. tlLoadLocker = true;
  209. Ext.Ajax.request({
  210. url: '/lib/controller/getGeoAlerts.php',
  211. params: {
  212. SITE: <?=$SiteID;?>,
  213. UID: <?=$UserID;?>,
  214. SID: '<?=$Session;?>',
  215. MODE: Mode
  216. },
  217. success: function( response, opts ){
  218. if( cevt.length ){
  219. for( i=0; i< cevt.length; i++ ){
  220. if( cevt[i]!= null ){
  221. cevt[i].remove();
  222. delete( cevt[i] );
  223. cevt[i] = null;
  224. };
  225. };
  226. };
  227. if( coz.length ){
  228. for( i=0; i< coz.length; i++ ){
  229. if( coz[i]!= null ){
  230. coz[i].remove();
  231. delete( coz[i] );
  232. coz[i]=null;
  233. };
  234. };
  235. };
  236. var data = Ext.decode( response.responseText );
  237. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  238. for( i=0; i < data.evt.length; i++ ){
  239. 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 ){
  240. loadEventProperties( this.options.id );
  241. } );
  242. cevt[i].addTo(map);
  243. };
  244. for( i=0; i < data.other.length; i++ ){
  245. switch( data.other[i].type ){
  246. case 'circle':{
  247. 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 } );
  248. coz[i].addTo(map);
  249. break;
  250. };
  251. };
  252. };
  253. //eventsListStore.reload();
  254. tlLoadLocker = false;
  255. },
  256. failure: function( response, opts ) {
  257. //Ext.fly('some_div').update('Fail!');
  258. tlLoadLocker = false;
  259. }
  260. });
  261. };
  262. function initMapMonitoring(){
  263. var aK = true;
  264. if( MAP_SET.attribution == '' ) aK = false;
  265. var mapLayers = [];
  266. if( map != null ){
  267. map.off();
  268. map.remove();
  269. };
  270. if( MAP_SET.type == 1 ){
  271. map = L.map( 'event_map',{
  272. //attributionControl: aK,
  273. attributionControl: false,
  274. preferCanvas: true,
  275. zoomControl: true,
  276. center: [SiteLat, SiteLon],
  277. /*zoomControl: false,
  278. zoom: 17,
  279. minZoom: 17,
  280. maxZoom: 17,*/
  281. keyboard: false
  282. });
  283. //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
  284. // attribution: MAP_SET.attribution,
  285. // maxNativeZoom: MAP_SET.maxNativeZoom,
  286. // maxZoom: MAP_SET.maxZoom
  287. //});
  288. L.tileLayer( MAP_SET.layer_url, {
  289. attribution: MAP_SET.attribution,
  290. attributionControl: false,
  291. maxNativeZoom: MAP_SET.maxNativeZoom,
  292. minZoom: 0,
  293. maxZoom: MAP_SET.maxZoom
  294. }).addTo( map );
  295. } else {
  296. map = L.map( 'event_map',{
  297. crs: L.CRS.Simple,
  298. attributionControl: false,
  299. preferCanvas: true,
  300. zoomControl: true,
  301. center: [SiteLat, SiteLon],
  302. /*zoomControl: false,*/
  303. zoom: 0,
  304. minZoom: 0,
  305. maxZoom: 4,
  306. keyboard: false
  307. });
  308. var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
  309. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
  310. }
  311. map.setView([SiteLat, SiteLon], 17 );
  312. loadMapZones( 0 );
  313. };
  314. function initMapMonitoring_00(){
  315. map = L.map('event_map',{
  316. attributionControl: true,
  317. //preferCanvas: true,
  318. zoomControl: true,
  319. center: [SiteLat, SiteLon],
  320. /*zoomControl: false,
  321. zoom: 17,
  322. minZoom: 17,
  323. maxZoom: 17,*/
  324. keyboard: false
  325. }).setView([SiteLat, SiteLon], 17);
  326. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  327. var mapLayers = [];
  328. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  329. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  330. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  331. detectRetina: true
  332. });*/
  333. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  334. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  335. maxNativeZoom: 18,
  336. maxZoom: 24,
  337. })
  338. // https://leaflet-extras.github.io/leaflet-providers/preview/
  339. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  340. 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',
  341. maxZoom: 19
  342. });
  343. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  344. 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',
  345. maxZoom: 19
  346. });
  347. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  348. 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',
  349. maxZoom: 24
  350. });
  351. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  352. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  353. maxZoom: 19
  354. });
  355. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  356. 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>) ',
  357. maxZoom: 19
  358. });
  359. /*
  360. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  361. 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>',
  362. maxZoom: 22
  363. });
  364. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  365. 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>',
  366. maxZoom: 22
  367. });
  368. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  369. 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>',
  370. maxZoom: 22
  371. });
  372. */
  373. var baseMaps = {
  374. "MyMap": mapLayers["MyMap"],
  375. "OpenStreetMap": mapLayers["OpenStreetMap"],
  376. "OpenTopoMap": mapLayers["OpenTopoMap"],
  377. "EsriSat": mapLayers["EsriSat"],
  378. "EsriStreet": mapLayers["EsriStreet"],
  379. "EsriTopo": mapLayers["EsriTopo"],
  380. //"Bing": mapLayers["Bing"],
  381. //"OSM-Cycle": mapLayers["Cycle"],
  382. //"Landscape": mapLayers["Landscape"],
  383. //"Outdoor": mapLayers["Outdoor"],
  384. };
  385. L.control.layers( baseMaps ).addTo(map);
  386. mapLayers["MyMap"].addTo(map);
  387. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  388. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  389. maxNativeZoom: 18,
  390. maxZoom: 24,
  391. }).addTo(map); */
  392. //loadTimeLineGroups( selectedSite );
  393. loadMapZones( 0 );
  394. //getData( 'arch' );
  395. };
  396. var iconSaver = null;
  397. var markerSaver = null;
  398. function updateLocation( e ){
  399. locationSelectedNode = e.target.options.mycustomid;
  400. Ext.Ajax.request({
  401. url: '/lib/controller/updateLocation.php',
  402. params: {
  403. NODE: locationSelectedNode,
  404. SITE: <?=$SiteID;?>,
  405. UID: <?=$UserID;?>,
  406. TYPE: 0,
  407. SID: '<?=$Session;?>',
  408. LAT: e.target._latlng.lat,
  409. LON: e.target._latlng.lng
  410. },
  411. success: function( response, opts ){
  412. loadNodeLocationProps( locationSelectedNode );
  413. },
  414. failure: failureAJAXFunction
  415. });
  416. };
  417. function markerDblClick( e ){
  418. if( iconSaver == null ){
  419. iconSaver = e.target.options.icon;
  420. markerSaver = e.target;
  421. e.target.setIcon( SNAPE_Icon );
  422. for( i=0; i< markers.length; i++){
  423. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  424. markers[i].setOpacity( 0.1 );
  425. } else {
  426. markers[i].setOpacity( 1.0 );
  427. }
  428. };
  429. } else {
  430. if( e.target.options.mycustomid == markerSaver.options.mycustomid ){
  431. e.target.setIcon( iconSaver );
  432. iconSaver = null;
  433. markerSaver = null;
  434. for( i=0; i< markers.length; i++){
  435. markers[i].setOpacity( 1.0 );
  436. };
  437. } else {
  438. markerSaver.setIcon( iconSaver );
  439. iconSaver = e.target.options.icon;
  440. markerSaver = e.target;
  441. e.target.setIcon( SNAPE_Icon );
  442. for( i=0; i< markers.length; i++){
  443. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  444. markers[i].setOpacity( 0.1 );
  445. } else {
  446. markers[i].setOpacity( 1.0 );
  447. }
  448. };
  449. };
  450. };
  451. };
  452. function setNodeLocationToAnchor(){
  453. Ext.Ajax.request({
  454. url: '/lib/controller/updateLocation.php',
  455. params: {
  456. NODE: locationSelectedNode,
  457. SITE: <?=$SiteID;?>,
  458. UID: <?=$UserID;?>,
  459. TYPE: 0,
  460. SID: '<?=$Session;?>',
  461. LAT: SiteLat,
  462. LON: SiteLon,
  463. ALT: SiteAlt
  464. },
  465. success: function( response, opts ){
  466. loadLocationEditor('sys_location_map');
  467. },
  468. failure: failureAJAXFunction
  469. });
  470. };
  471. function setNodeLocationByDelta(){
  472. var dx = Ext.getCmp('dx').getValue();
  473. var dy = Ext.getCmp('dy').getValue();
  474. var dz = Ext.getCmp('dz').getValue();
  475. Ext.Ajax.request({
  476. url: '/lib/controller/updateLocation.php',
  477. params: {
  478. NODE: locationSelectedNode,
  479. SITE: <?=$SiteID;?>,
  480. UID: <?=$UserID;?>,
  481. TYPE: 3,
  482. SID: '<?=$Session;?>',
  483. LAT: dx,
  484. LON: dy,
  485. ALT: dz
  486. },
  487. success: function( response, opts ){
  488. loadLocationEditor('sys_location_map');
  489. },
  490. failure: failureAJAXFunction
  491. });
  492. };
  493. var LRF3D_Icon = L.icon({
  494. iconUrl: '/style/assets/5_node.png',
  495. //shadowUrl: 'leaf-shadow.png',
  496. iconSize: [64, 64], // size of the icon
  497. //shadowSize: [50, 64], // size of the shadow
  498. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  499. //shadowAnchor: [4, 62], // the same for the shadow
  500. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  501. });
  502. var LFS_Icon = L.icon({
  503. iconUrl: '/style/assets/2_node.png',
  504. //shadowUrl: 'leaf-shadow.png',
  505. iconSize: [64, 64], // size of the icon
  506. //shadowSize: [50, 64], // size of the shadow
  507. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  508. //shadowAnchor: [4, 62], // the same for the shadow
  509. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  510. });
  511. var PLS200_Icon = L.icon({
  512. iconUrl: '/style/assets/3_node.png',
  513. //shadowUrl: 'leaf-shadow.png',
  514. iconSize: [64, 64], // size of the icon
  515. //shadowSize: [50, 64], // size of the shadow
  516. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  517. //shadowAnchor: [4, 62], // the same for the shadow
  518. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  519. });
  520. var PLSNET200_Icon = L.icon({
  521. iconUrl: '/style/assets/6_node.png',
  522. //shadowUrl: 'leaf-shadow.png',
  523. iconSize: [64, 64], // size of the icon
  524. //shadowSize: [50, 64], // size of the shadow
  525. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  526. //shadowAnchor: [4, 62], // the same for the shadow
  527. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  528. });
  529. var PLS360_Icon = L.icon({
  530. iconUrl: '/style/assets/4_node.png',
  531. //shadowUrl: 'leaf-shadow.png',
  532. iconSize: [64, 64], // size of the icon
  533. //shadowSize: [50, 64], // size of the shadow
  534. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  535. //shadowAnchor: [4, 62], // the same for the shadow
  536. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  537. });
  538. var ALS_Icon = L.icon({
  539. iconUrl: '/style/assets/1_node.png',
  540. //shadowUrl: 'leaf-shadow.png',
  541. iconSize: [64, 64], // size of the icon
  542. //shadowSize: [50, 64], // size of the shadow
  543. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  544. //shadowAnchor: [4, 62], // the same for the shadow
  545. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  546. });
  547. var PTZCAM_Icon = L.icon({
  548. iconUrl: '/style/assets/12_node.png',
  549. //shadowUrl: 'leaf-shadow.png',
  550. iconSize: [64, 64], // size of the icon
  551. //shadowSize: [50, 64], // size of the shadow
  552. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  553. //shadowAnchor: [4, 62], // the same for the shadow
  554. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  555. });
  556. var FIXCAM_Icon = L.icon({
  557. iconUrl: '/style/assets/11_node.png',
  558. //shadowUrl: 'leaf-shadow.png',
  559. iconSize: [64, 64], // size of the icon
  560. //shadowSize: [50, 64], // size of the shadow
  561. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  562. //shadowAnchor: [4, 62], // the same for the shadow
  563. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  564. });
  565. var SITEZ_Icon = L.icon({
  566. iconUrl: '/style/assets/centre_1.png',
  567. //shadowUrl: 'leaf-shadow.png',
  568. iconSize: [32, 32], // size of the icon
  569. //shadowSize: [50, 64], // size of the shadow
  570. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  571. //shadowAnchor: [4, 62], // the same for the shadow
  572. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  573. });
  574. var SNAPE_Icon = L.icon({
  575. iconUrl: '/style/assets/cursor.png',
  576. //shadowUrl: 'leaf-shadow.png',
  577. iconSize: [32, 32], // size of the icon
  578. //shadowSize: [50, 64], // size of the shadow
  579. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  580. //shadowAnchor: [4, 62], // the same for the shadow
  581. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  582. });
  583. function loadLocationNodes(){
  584. Ext.Ajax.request({
  585. url: '/lib/controller/getLocationItems.php',
  586. params: {
  587. SITE: <?=$SiteID;?>,
  588. UID: <?=$UserID;?>,
  589. SID: '<?=$Session;?>'
  590. },
  591. success: function( response, opts ){
  592. var data = Ext.decode(response.responseText);
  593. if( data!= null ){
  594. var i = 0;
  595. var tall = Array();
  596. for( ; i < data.length; i++){
  597. switch( data[i].type ){
  598. case 1:{
  599. 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 );
  600. break;
  601. };
  602. case 2:{
  603. 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 );
  604. break;
  605. };
  606. case 3:{
  607. 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 );
  608. break;
  609. };
  610. case 4:{
  611. 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 );
  612. break;
  613. };
  614. case 5:{
  615. 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 );
  616. break;
  617. };
  618. case 6:{
  619. 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 );
  620. break;
  621. };
  622. case 10:
  623. case 12:{
  624. 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 );
  625. break;
  626. };
  627. case 11:
  628. case 13:{
  629. 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 );
  630. break;
  631. };
  632. };
  633. tall[i] = markers[i];
  634. };
  635. tall[i++] = ed_anchor;
  636. var cVisible = L.featureGroup( tall );
  637. map_ed.flyToBounds( cVisible.getBounds() );
  638. } else {
  639. map_ed.setView([SiteLat, SiteLon], 4 );
  640. };
  641. },
  642. failure: function( response, opts ) {
  643. //var tPanel = Ext.getCmp('main_portal');
  644. //tPanel.remove(0);
  645. //tPanel.add( { html: 'Failed to load dashboard!' } );
  646. //tPanel.doLayout();
  647. }
  648. });
  649. };
  650. function orientationEditor(){
  651. if( orientationEditorWindow == null ){
  652. orientationEditorWindow = new Ext.Window({
  653. modal: true,
  654. title: 'Orientation',
  655. closeAction: 'hide',
  656. width: 640,
  657. height: 500,
  658. items:[{
  659. layout: 'table',
  660. defaults: {
  661. bodyStyle:'padding:5px'
  662. },
  663. layoutConfig: {
  664. columns: 3
  665. },
  666. items:[{
  667. html: 'Roll:'
  668. },{
  669. xtype: 'textfield',
  670. id: 'roll',
  671. name: 'roll',
  672. value: 30.0029,
  673. listeners:{
  674. change: function( sl, nv, tt ){
  675. setCubeOrientation( nv / 1.0, curY, curZ );
  676. }
  677. }
  678. },{
  679. xtype: 'slider',
  680. id: 'roll_sld',
  681. width: 200,
  682. value: 30.0029,
  683. minValue: -180.0,
  684. maxValue: 180.0,
  685. listeners:{
  686. change: function( sl, nv, tt ){
  687. setCubeOrientation( nv, curY, curZ );
  688. }
  689. }
  690. },{
  691. html: 'Pitch:'
  692. },{
  693. xtype: 'textfield',
  694. id: 'pitch',
  695. name: 'pitch',
  696. value: 30.0029,
  697. listeners:{
  698. change: function( sl, nv, tt ){
  699. setCubeOrientation( curX, nv / 1.0, curZ );
  700. }
  701. }
  702. },{
  703. xtype: 'slider',
  704. id: 'pitch_sld',
  705. width: 200,
  706. value: 30.0029,
  707. minValue: -180.0,
  708. maxValue: 180.0,
  709. listeners:{
  710. change: function( sl, nv, tt ){
  711. setCubeOrientation( curX, nv, curZ );
  712. }
  713. }
  714. },{
  715. html: 'Yaw:'
  716. },{
  717. xtype: 'textfield',
  718. id: 'yaw',
  719. name: 'yaw',
  720. value: 30.0029,
  721. listeners:{
  722. change: function( sl, nv, tt ){
  723. //alert( nv );
  724. setCubeOrientation( curX, curY, nv / 1.0 );
  725. }
  726. }
  727. },{
  728. xtype: 'slider',
  729. id: 'yaw_sld',
  730. width: 200,
  731. value: 30.0029,
  732. minValue: -180.0,
  733. maxValue: 180.0,
  734. listeners:{
  735. change: function( sl, nv, tt ){
  736. setCubeOrientation( curX, curY, nv );
  737. }
  738. }
  739. }]
  740. },{
  741. 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>'
  742. }],
  743. buttons:[{
  744. text: 'Cancel',
  745. width: 200,
  746. handler: function(){
  747. orientationEditorWindow.hide();
  748. }
  749. },{
  750. text: 'Apply',
  751. width: 200,
  752. handler: function(){
  753. Ext.getCmp('sroll').setValue( Ext.getCmp('roll').getValue() );
  754. Ext.getCmp('spitch').setValue( Ext.getCmp('pitch').getValue() );
  755. Ext.getCmp('syaw').setValue( Ext.getCmp('yaw').getValue() );
  756. orientationEditorWindow.hide();
  757. }
  758. }]
  759. });
  760. orientationEditorWindow.show();
  761. cubeViewport = new Viewport({
  762. element: document.getElementsByClassName('cube')[0],
  763. fps: 20,
  764. sensivity: .1,
  765. sensivityFade: .93,
  766. speed: 2,
  767. touchSensivity: 1.5
  768. });
  769. cube = new Cube({
  770. viewport: cubeViewport,
  771. element: document.getElementsByClassName('cube')[0]
  772. });
  773. } else {
  774. orientationEditorWindow.show();
  775. };
  776. setCubeOrientation( Ext.getCmp('sroll').getValue(), Ext.getCmp('spitch').getValue(), Ext.getCmp('syaw').getValue() );
  777. };
  778. var locationSelectedNode = 0;
  779. function loadLoactionProps( e ){
  780. if( typeof e == 'number' ){
  781. locationSelectedNode = e;
  782. } else {
  783. locationSelectedNode = e.sourceTarget.options.mycustomid;
  784. }
  785. loadNodeLocationProps( locationSelectedNode );
  786. };
  787. function loadNodeLocationProps( NodeID ){
  788. //alert( 'Node: ' + NodeID );
  789. Ext.Ajax.request({
  790. url: '/lib/controller/getLocationNodeProps.php',
  791. params: {
  792. NID: <?=$SiteID;?>,
  793. UID: <?=$UserID;?>,
  794. SID: '<?=$Session;?>',
  795. NODE: NodeID
  796. },
  797. success: function( response, opts ){
  798. // If the response is JSON, you have to decode it
  799. var data = Ext.decode(response.responseText);
  800. var tPanel = Ext.getCmp('prop_content');
  801. tPanel.remove(0);
  802. tPanel.add( data );
  803. tPanel.doLayout();
  804. },
  805. failure: failureAJAXFunction
  806. });
  807. };
  808. function LoadNodesList(){
  809. Ext.Ajax.request({
  810. url: '/lib/controller/getLocationNodes.php',
  811. params: {
  812. SITE: <?=$SiteID;?>,
  813. UID: <?=$UserID;?>,
  814. SID: '<?=$Session;?>'
  815. },
  816. success: function( response, opts ){
  817. var data = Ext.decode(response.responseText);
  818. var tPanel = Ext.getCmp('prop_content');
  819. tPanel.remove(0);
  820. tPanel.add( data );
  821. tPanel.doLayout();
  822. },
  823. failure: failureAJAXFunction
  824. });
  825. };
  826. function reloadSiteMapData(){
  827. Ext.Ajax.request({
  828. url: '/lib/controller/getMapData.php',
  829. params: {
  830. SITE: <?=$SiteID;?>,
  831. UID: <?=$UserID;?>,
  832. SID: '<?=$Session;?>'
  833. },
  834. success: function( response, opts ){
  835. var data = Ext.decode(response.responseText);
  836. MAP_ID = parseInt( data.selected_map );
  837. MAP_IS_LOCAL = (MAP_ID)?data.local_binding:false;
  838. MAP_SET = data.maps;
  839. Ext.getCmp('lab_123').update( '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> '+((MAP_IS_LOCAL)?'Pos X':'<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>')+':' );
  840. Ext.getCmp('lab_124').update( ((MAP_IS_LOCAL)?'Pos Y':'<?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>')+':' );
  841. document.getElementById('lab_125').src = ((MAP_IS_LOCAL)?'/style/assets/map_mode_decart.png':'/style/assets/map_mode_wgs84.png');
  842. loadLocationEditor('sys_location_map');
  843. },
  844. failure: failureAJAXFunction
  845. });
  846. };
  847. var ed_anchor = null;
  848. function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
  849. if( tlInterval!= null ){
  850. window.clearInterval( tlInterval );
  851. tlInterval = null;
  852. timelineObj = null;
  853. };
  854. if( node_type == undefined ) node_type = 0;
  855. if( lat == undefined ){
  856. lat = SiteLat;
  857. lon = SiteLon;
  858. };
  859. //var cMSET = mapListStore.getAt( MAP_ID );
  860. //alert( MAP_SET.id );
  861. var aK = true;
  862. if( MAP_SET.attribution == '' ) aK = false;
  863. var mapLayers = [];
  864. if( map_ed != undefined ){
  865. map_ed.off();
  866. map_ed.remove();
  867. };
  868. if( MAP_SET.type == 1 ){
  869. map_ed = L.map( el_id,{
  870. attributionControl: aK,
  871. //preferCanvas: true,
  872. zoomControl: true,
  873. center: [SiteLat, SiteLon],
  874. /*zoomControl: false,
  875. zoom: 17,
  876. minZoom: 17,
  877. maxZoom: 17,*/
  878. keyboard: false
  879. });
  880. //mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
  881. // attribution: MAP_SET.attribution,
  882. // maxNativeZoom: MAP_SET.maxNativeZoom,
  883. // maxZoom: MAP_SET.maxZoom
  884. //});
  885. L.tileLayer( MAP_SET.layer_url, {
  886. attribution: MAP_SET.attribution,
  887. maxNativeZoom: MAP_SET.maxNativeZoom,
  888. minZoom: 0,
  889. maxZoom: MAP_SET.maxZoom
  890. }).addTo( map_ed );
  891. } else {
  892. map_ed = L.map( el_id,{
  893. crs: L.CRS.Simple,
  894. attributionControl: false,
  895. preferCanvas: true,
  896. zoomControl: true,
  897. center: [SiteLat, SiteLon],
  898. /*zoomControl: false,*/
  899. zoom: 0,
  900. minZoom: 0,
  901. maxZoom: 4,
  902. keyboard: false
  903. });
  904. var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
  905. var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map_ed );
  906. }
  907. map_ed.setView([SiteLat, SiteLon], MAP_SET.maxZoom);
  908. if( node_type ){
  909. 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();
  910. } else {
  911. 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();
  912. };
  913. /*
  914. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  915. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  916. maxNativeZoom: 18,
  917. maxZoom: 24,
  918. })
  919. // https://leaflet-extras.github.io/leaflet-providers/preview/
  920. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  921. 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',
  922. maxZoom: 19
  923. });
  924. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  925. 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',
  926. maxZoom: 19
  927. });
  928. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  929. 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',
  930. maxZoom: 24
  931. });
  932. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  933. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  934. maxZoom: 19
  935. });
  936. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  937. 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>) ',
  938. maxZoom: 19
  939. });
  940. var baseMaps = {
  941. "MyMap": mapLayers["MyMap"],
  942. "OpenStreetMap": mapLayers["OpenStreetMap"],
  943. "OpenTopoMap": mapLayers["OpenTopoMap"],
  944. "EsriSat": mapLayers["EsriSat"],
  945. "EsriStreet": mapLayers["EsriStreet"],
  946. "EsriTopo": mapLayers["EsriTopo"],
  947. //"Bing": mapLayers["Bing"],
  948. //"OSM-Cycle": mapLayers["Cycle"],
  949. //"Landscape": mapLayers["Landscape"],
  950. //"Outdoor": mapLayers["Outdoor"],
  951. };
  952. L.control.layers( baseMaps ).addTo( map_ed );
  953. mapLayers["MyMap"].addTo( map_ed );
  954. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  955. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  956. }).addTo( map_ed );
  957. */
  958. if( node_type ){
  959. switch( node_type ){
  960. case 1:{
  961. 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 );
  962. break;
  963. };
  964. case 2:{
  965. 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 );
  966. break;
  967. };
  968. case 3:{
  969. 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 );
  970. break;
  971. };
  972. case 4:{
  973. 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 );
  974. break;
  975. };
  976. case 5:{
  977. 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 );
  978. break;
  979. };
  980. case 6:{
  981. 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 );
  982. break;
  983. };
  984. case 10:
  985. case 12:{
  986. 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 );
  987. break;
  988. };
  989. case 11:
  990. case 13:{
  991. 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 );
  992. break;
  993. };
  994. };
  995. } else loadLocationNodes();
  996. };
  997. function updateSiteAnchor(){
  998. SiteLat = Ext.getCmp('siteLat').getValue();
  999. SiteLon = Ext.getCmp('siteLon').getValue();
  1000. SiteAlt = Ext.getCmp('siteAlt').getValue();
  1001. Ext.Ajax.request({
  1002. url: '/lib/controller/updateLocation.php',
  1003. params: {
  1004. SITE: <?=$SiteID;?>,
  1005. UID: <?=$UserID;?>,
  1006. TYPE: 1,
  1007. SID: '<?=$Session;?>',
  1008. LAT: SiteLat,
  1009. LON: SiteLon,
  1010. ALT: SiteAlt
  1011. },
  1012. success: function(){
  1013. loadLocationEditor('sys_location_map');
  1014. },
  1015. failure: failureAJAXFunction
  1016. });
  1017. };
  1018. function updateSiteMap(){
  1019. MAP_ID = Ext.getCmp('siteMap').getValue();
  1020. Ext.Ajax.request({
  1021. url: '/lib/controller/updateLocation.php',
  1022. params: {
  1023. SITE: <?=$SiteID;?>,
  1024. UID: <?=$UserID;?>,
  1025. TYPE: 4,
  1026. SID: '<?=$Session;?>',
  1027. MID: MAP_ID
  1028. },
  1029. success: function( response, opts ){
  1030. reloadSiteMapData();
  1031. },
  1032. failure: failureAJAXFunction
  1033. });
  1034. };
  1035. var mapDataLoadded = false;
  1036. // Call this to prepare all data once in Session
  1037. function prepareMapData(){
  1038. //if( ap_type == 1 ) return;//Metro No Map ...
  1039. if( !mapDataLoadded ){
  1040. mapListStore.load();
  1041. };
  1042. };
  1043. function updateLocationOrientation(){
  1044. var tLat = Ext.getCmp('slat').getValue();
  1045. var tLon = Ext.getCmp('slon').getValue();
  1046. var tAlt = Ext.getCmp('salt').getValue();
  1047. var tRoll = Ext.getCmp('sroll').getValue();
  1048. var tPitch = Ext.getCmp('spitch').getValue();
  1049. var tYaw = Ext.getCmp('syaw').getValue();
  1050. Ext.Ajax.request({
  1051. url: '/lib/controller/updateLocation.php',
  1052. params: {
  1053. NODE: locationSelectedNode,
  1054. UID: <?=$UserID;?>,
  1055. TYPE: 2,
  1056. SID: '<?=$Session;?>',
  1057. LAT: tLat,
  1058. LON: tLon,
  1059. ALT: tAlt,
  1060. YAW: tYaw,
  1061. ROLL: tRoll,
  1062. PITCH: tPitch
  1063. },
  1064. failure: failureAJAXFunction
  1065. });
  1066. };
  1067. var iconSaver = null;
  1068. var markerSaver = null;
  1069. function updateLocation( e ){
  1070. locationSelectedNode = e.target.options.mycustomid;
  1071. Ext.Ajax.request({
  1072. url: '/lib/controller/updateLocation.php',
  1073. params: {
  1074. NODE: locationSelectedNode,
  1075. SITE: <?=$SiteID;?>,
  1076. UID: <?=$UserID;?>,
  1077. TYPE: 0,
  1078. SID: '<?=$Session;?>',
  1079. LAT: e.target._latlng.lat,
  1080. LON: e.target._latlng.lng
  1081. },
  1082. success: function( response, opts ){
  1083. loadNodeLocationProps( locationSelectedNode );
  1084. },
  1085. failure: failureAJAXFunction
  1086. });
  1087. };
  1088. function markerDblClick( e ){
  1089. if( iconSaver == null ){
  1090. iconSaver = e.target.options.icon;
  1091. markerSaver = e.target;
  1092. e.target.setIcon( SNAPE_Icon );
  1093. for( i=0; i< markers.length; i++){
  1094. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  1095. markers[i].setOpacity( 0.1 );
  1096. } else {
  1097. markers[i].setOpacity( 1.0 );
  1098. }
  1099. };
  1100. } else {
  1101. if( e.target.options.mycustomid == markerSaver.options.mycustomid ){
  1102. e.target.setIcon( iconSaver );
  1103. iconSaver = null;
  1104. markerSaver = null;
  1105. for( i=0; i< markers.length; i++){
  1106. markers[i].setOpacity( 1.0 );
  1107. };
  1108. } else {
  1109. markerSaver.setIcon( iconSaver );
  1110. iconSaver = e.target.options.icon;
  1111. markerSaver = e.target;
  1112. e.target.setIcon( SNAPE_Icon );
  1113. for( i=0; i< markers.length; i++){
  1114. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  1115. markers[i].setOpacity( 0.1 );
  1116. } else {
  1117. markers[i].setOpacity( 1.0 );
  1118. }
  1119. };
  1120. };
  1121. };
  1122. };
  1123. /*
  1124. function setNodeLocationToAnchor(){
  1125. Ext.Ajax.request({
  1126. url: '/lib/controller/updateLocation.php',
  1127. params: {
  1128. NODE: locationSelectedNode,
  1129. SITE: <?=$SiteID;?>,
  1130. UID: <?=$UserID;?>,
  1131. TYPE: 0,
  1132. SID: '<?=$Session;?>',
  1133. LAT: SiteLat,
  1134. LON: SiteLon,
  1135. ALT: SiteAlt
  1136. },
  1137. success: function( response, opts ){
  1138. loadLocationEditor('sys_location_map');
  1139. },
  1140. failure: failureAJAXFunction
  1141. });
  1142. };
  1143. function setNodeLocationByDelta(){
  1144. var dx = Ext.getCmp('dx').getValue();
  1145. var dy = Ext.getCmp('dy').getValue();
  1146. var dz = Ext.getCmp('dz').getValue();
  1147. Ext.Ajax.request({
  1148. url: '/lib/controller/updateLocation.php',
  1149. params: {
  1150. NODE: locationSelectedNode,
  1151. SITE: <?=$SiteID;?>,
  1152. UID: <?=$UserID;?>,
  1153. TYPE: 3,
  1154. SID: '<?=$Session;?>',
  1155. LAT: dx,
  1156. LON: dy,
  1157. ALT: dz
  1158. },
  1159. success: function( response, opts ){
  1160. loadLocationEditor();
  1161. },
  1162. failure: failureAJAXFunction
  1163. });
  1164. };
  1165. */
  1166. var mapCreatorWindow = null;
  1167. function createNewMap(){
  1168. if( mapCreatorWindow == null ){
  1169. mapCreatorWindow = new Ext.Window({
  1170. width: 800,
  1171. height: 440,
  1172. title: 'Creeate Custom Map',
  1173. modal: true,
  1174. frame: true,
  1175. border: false,
  1176. resizable: false,
  1177. items: [{
  1178. xtype: 'tabpanel',
  1179. id: 'mcr_tbp',
  1180. activeTab: 0,
  1181. items:[{
  1182. xtype: 'form',
  1183. title: 'Internet Map',
  1184. id: 'map_map_frm',
  1185. labelWidth: 250,
  1186. labelAlign: 'right',
  1187. height: 350,
  1188. items:[{
  1189. xtype: 'textfield',
  1190. fieldLabel: 'Map Name',
  1191. name: 'map_name',
  1192. width: 540,
  1193. },{
  1194. xtype: 'hidden',
  1195. name: 'ctype',
  1196. value: 1
  1197. },{
  1198. xtype: 'textfield',
  1199. fieldLabel: 'Tiles URL Pattern',
  1200. name: 'map_url',
  1201. width: 540,
  1202. },{
  1203. xtype: 'textfield',
  1204. fieldLabel: 'Layer Attribution',
  1205. name: 'map_attr',
  1206. width: 540,
  1207. },{
  1208. xtype: 'textarea',
  1209. fieldLabel: 'Description',
  1210. name: 'map_desc',
  1211. width: 540,
  1212. },{
  1213. xtype: 'combo',
  1214. fieldLabel: 'Max Zoom',
  1215. name: 'map_maxz',
  1216. editable: false,
  1217. typeAhead: true,
  1218. triggerAction: 'all',
  1219. width: 100,
  1220. lazyRender:true,
  1221. mode: 'local',
  1222. store: new Ext.data.ArrayStore({
  1223. fields: ['zoom_l'],
  1224. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1225. }),
  1226. value: '18',
  1227. valueField: 'zoom_l',
  1228. displayField: 'zoom_l'
  1229. },{
  1230. xtype: 'combo',
  1231. fieldLabel: 'Max Native Zoom',
  1232. name: 'map_maxnz',
  1233. editable: false,
  1234. typeAhead: true,
  1235. triggerAction: 'all',
  1236. width: 100,
  1237. lazyRender:true,
  1238. mode: 'local',
  1239. store: new Ext.data.ArrayStore({
  1240. fields: ['zoom_l'],
  1241. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1242. }),
  1243. value: '16',
  1244. valueField: 'zoom_l',
  1245. displayField: 'zoom_l'
  1246. }]
  1247. },{
  1248. xtype: 'form',
  1249. title: 'Local Picture Map',
  1250. id: 'map_pic_frm',
  1251. fileUpload: true,
  1252. height: 350,
  1253. //autoHeight: true,
  1254. //bodyStyle: 'padding: 10px 10px 0 10px;',
  1255. labelWidth: 250,
  1256. labelAlign: 'right',
  1257. defaults: {
  1258. //anchor: '95%',
  1259. //allowBlank: false,
  1260. msgTarget: 'side'
  1261. },
  1262. items: [{
  1263. xtype: 'textfield',
  1264. fieldLabel: '<?=$Labels->GetLabel('_MAP_NAME_');?>',
  1265. id: 'map_name_2',
  1266. name: 'map_name',
  1267. width: 540
  1268. },{
  1269. xtype: 'hidden',
  1270. name: 'ctype',
  1271. value: 2
  1272. },{
  1273. xtype: 'fileuploadfield',
  1274. id: 'form-file',
  1275. emptyText: '<?=$Labels->GetLabel('_SELE_ANIMAGE_');?>',
  1276. fieldLabel: '<?=$Labels->GetLabel('_MAP_PICTURE_');?>',
  1277. width: 500,
  1278. name: 'map_image',
  1279. buttonText: '<?=$Labels->GetLabel('_BROWSE_');?>'
  1280. },{
  1281. xtype: 'textfield',
  1282. fieldLabel: '<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>',
  1283. name: 'map_attr',
  1284. width: 540,
  1285. },{
  1286. xtype: 'textarea',
  1287. fieldLabel: '<?=$Labels->GetLabel('_DESCRIPTION_');?>',
  1288. name: 'map_desc',
  1289. width: 540,
  1290. },{
  1291. xtype: 'combo',
  1292. fieldLabel: '<?=$Labels->GetLabel('_MAX_ZOOM_');?>',
  1293. editable: false,
  1294. typeAhead: true,
  1295. name: 'map_maxz',
  1296. triggerAction: 'all',
  1297. width: 100,
  1298. lazyRender:true,
  1299. mode: 'local',
  1300. store: new Ext.data.ArrayStore({
  1301. fields: ['zoom_l'],
  1302. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1303. }),
  1304. value: '16',
  1305. valueField: 'zoom_l',
  1306. displayField: 'zoom_l'
  1307. },{
  1308. xtype: 'combo',
  1309. fieldLabel: '<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>',
  1310. editable: false,
  1311. typeAhead: true,
  1312. name: 'map_maxnz',
  1313. triggerAction: 'all',
  1314. width: 100,
  1315. lazyRender:true,
  1316. mode: 'local',
  1317. store: new Ext.data.ArrayStore({
  1318. fields: ['zoom_l'],
  1319. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1320. }),
  1321. value: '16',
  1322. valueField: 'zoom_l',
  1323. displayField: 'zoom_l'
  1324. },{
  1325. xtype: 'numberfield',
  1326. fieldLabel: '<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>',
  1327. name: 'map_tpb',
  1328. value: 0,
  1329. width: 540,
  1330. },{
  1331. xtype: 'numberfield',
  1332. fieldLabel: '<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>',
  1333. name: 'map_lpb',
  1334. value: 0,
  1335. width: 540,
  1336. },{
  1337. xtype: 'numberfield',
  1338. fieldLabel: '<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>',
  1339. name: 'map_rpb',
  1340. value: 0,
  1341. width: 540,
  1342. },{
  1343. xtype: 'numberfield',
  1344. fieldLabel: '<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>',
  1345. name: 'map_bpb',
  1346. value: 0,
  1347. width: 540,
  1348. },{
  1349. xtype: 'numberfield',
  1350. fieldLabel: '<?=$Labels->GetLabel('_MAP_WIDTH_');?>',
  1351. name: 'map_width',
  1352. decimalPrecision: 2,
  1353. value: 1000.00,
  1354. width: 540,
  1355. },{
  1356. xtype: 'numberfield',
  1357. fieldLabel: '<?=$Labels->GetLabel('_MAP_HEIGHT_');?>',
  1358. name: 'map_heigth',
  1359. decimalPrecision: 2,
  1360. value: 1000.00,
  1361. width: 540,
  1362. }]
  1363. }]
  1364. }],
  1365. bbar:[ '->',{
  1366. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  1367. handler: function(){
  1368. //Ext.getCmp('map_map_frm').getForm().reset();
  1369. //Ext.getCmp('map_pic_frm').getForm().reset();
  1370. mapCreatorEditorWindow.destroy();
  1371. }
  1372. },{
  1373. text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>',
  1374. handler: function(){
  1375. var tt = Ext.getCmp('mcr_tbp').getActiveTab();
  1376. if( tt.id == 'map_map_frm' ){
  1377. if( Ext.getCmp('map_map_frm').getForm().isValid()){
  1378. Ext.getCmp('map_map_frm').getForm().submit({
  1379. url: '/lib/controller/addMap.php',
  1380. waitMsg: 'Uploading Data...',
  1381. encoding: 'multipart/form-data',
  1382. success: function(fp, o){
  1383. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  1384. alert('Processed file on the server');
  1385. }
  1386. });
  1387. };
  1388. } else {
  1389. if( Ext.getCmp('map_pic_frm').getForm().isValid()){
  1390. Ext.getCmp('map_pic_frm').getForm().submit({
  1391. url: '/lib/controller/addMap.php',
  1392. waitMsg: 'Uploading Image...',
  1393. encoding: 'multipart/form-data',
  1394. success: function(fp, o){
  1395. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  1396. alert('Processed file on the server');
  1397. }
  1398. });
  1399. };
  1400. };
  1401. }
  1402. }],
  1403. listeners:{
  1404. beforedestroy: function(){
  1405. mapCreatorEditorWindow = null;
  1406. }
  1407. }
  1408. });
  1409. };
  1410. mapCreatorWindow.show();
  1411. };
  1412. var mapEditorWindow = null;
  1413. function editCurrentMap(){
  1414. Ext.Ajax.request({
  1415. url: '/lib/controller/getMapData.php',
  1416. params: {
  1417. SITE: <?=$SiteID;?>,
  1418. UID: <?=$UserID;?>,
  1419. MID: MAP_ID
  1420. },
  1421. success: function( response, opts ){
  1422. var newMapData = Ext.decode( response.responseText );
  1423. if( mapEditorWindow == null ){
  1424. switch( newMapData.type ){
  1425. case 1:{
  1426. mapEditorWindow = new Ext.Window({
  1427. width: 800,
  1428. height: 440,
  1429. title: 'Edit Current Map',
  1430. modal: true,
  1431. //closeAction: 'hide',
  1432. frame: true,
  1433. border: false,
  1434. resizable: false,
  1435. items: [{
  1436. xtype: 'form',
  1437. id: 'map_map_frm',
  1438. labelWidth: 250,
  1439. labelAlign: 'right',
  1440. height: 350,
  1441. items:[{
  1442. xtype: 'textfield',
  1443. fieldLabel: 'Map Name',
  1444. id: 'map_name_1',
  1445. name: 'map_name',
  1446. width: 540,
  1447. },{
  1448. xtype: 'hidden',
  1449. name: 'ctype',
  1450. value: 1
  1451. },{
  1452. xtype: 'textfield',
  1453. fieldLabel: 'Tiles URL Pattern',
  1454. name: 'map_url',
  1455. width: 540,
  1456. },{
  1457. xtype: 'textfield',
  1458. fieldLabel: 'Layer Attribution',
  1459. name: 'map_attr',
  1460. width: 540,
  1461. },{
  1462. xtype: 'textarea',
  1463. fieldLabel: 'Description',
  1464. name: 'map_desc',
  1465. width: 540,
  1466. },{
  1467. xtype: 'combo',
  1468. fieldLabel: 'Max Zoom',
  1469. name: 'map_maxz',
  1470. editable: false,
  1471. typeAhead: true,
  1472. triggerAction: 'all',
  1473. width: 100,
  1474. lazyRender:true,
  1475. mode: 'local',
  1476. store: new Ext.data.ArrayStore({
  1477. fields: ['zoom_l'],
  1478. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1479. }),
  1480. value: '18',
  1481. valueField: 'zoom_l',
  1482. displayField: 'zoom_l'
  1483. },{
  1484. xtype: 'combo',
  1485. fieldLabel: 'Max Native Zoom',
  1486. name: 'map_maxnz',
  1487. editable: false,
  1488. typeAhead: true,
  1489. triggerAction: 'all',
  1490. width: 100,
  1491. lazyRender:true,
  1492. mode: 'local',
  1493. store: new Ext.data.ArrayStore({
  1494. fields: ['zoom_l'],
  1495. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1496. }),
  1497. value: '16',
  1498. valueField: 'zoom_l',
  1499. displayField: 'zoom_l'
  1500. }]
  1501. }],
  1502. bbar:[ '->',{
  1503. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  1504. handler: function(){
  1505. mapEditorWindow.destroy();
  1506. }
  1507. },{
  1508. text: '<?=$Labels->GetLabel('_APPLY_CHANGES_');?>',
  1509. handler: function(){
  1510. var tt = Ext.getCmp('mcr_tbp').getActiveTab();
  1511. if( tt.id == 'map_map_frm' ){
  1512. if( Ext.getCmp('map_map_frm').getForm().isValid()){
  1513. Ext.getCmp('map_map_frm').getForm().submit({
  1514. url: '/lib/controller/addMap.php',
  1515. waitMsg: 'Uploading Image...',
  1516. encoding: 'multipart/form-data',
  1517. success: function(fp, o){
  1518. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  1519. alert('Processed file on the server');
  1520. }
  1521. });
  1522. };
  1523. } else {
  1524. if( Ext.getCmp('map_pic_frm').getForm().isValid()){
  1525. Ext.getCmp('map_pic_frm').getForm().submit({
  1526. url: '/lib/controller/addMap.php',
  1527. waitMsg: 'Uploading Image...',
  1528. encoding: 'multipart/form-data',
  1529. success: function(fp, o){
  1530. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  1531. alert('Processed file on the server');
  1532. }
  1533. });
  1534. };
  1535. };
  1536. }
  1537. }],
  1538. listeners: {
  1539. beforedestroy: function(){
  1540. mapEditorWindow = null;
  1541. }
  1542. }
  1543. });
  1544. break;
  1545. };
  1546. default:{
  1547. mapEditorWindow = new Ext.Window({
  1548. width: 800,
  1549. height: 540,
  1550. title: 'Edit Current Map',
  1551. modal: true,
  1552. //closeAction: 'hide',
  1553. frame: true,
  1554. border: false,
  1555. resizable: false,
  1556. items: [{
  1557. xtype: 'form',
  1558. id: 'map_edt_frm',
  1559. height: 480,
  1560. //autoHeight: true,
  1561. //bodyStyle: 'padding: 10px 10px 0 10px;',
  1562. labelWidth: 250,
  1563. labelAlign: 'right',
  1564. defaults: {
  1565. //anchor: '95%',
  1566. //allowBlank: false,
  1567. msgTarget: 'side'
  1568. },
  1569. items:[{
  1570. xtype: 'spacer',
  1571. height: 6
  1572. },{
  1573. xtype: 'textfield',
  1574. fieldLabel: '<?=$Labels->GetLabel('_MAP_NAME_');?>',
  1575. name: 'map_name',
  1576. value: newMapData.name,
  1577. width: 540
  1578. },{
  1579. xtype: 'hidden',
  1580. name: 'MID',
  1581. value: newMapData.id
  1582. },{
  1583. xtype: 'panel',
  1584. frame: false,
  1585. border: false,
  1586. html: '<center><img height="50px" SRC="/lib/controller/data/assets/images/'+MAP_SET.layer_url+'"></center>'
  1587. },{
  1588. xtype: 'textfield',
  1589. fieldLabel: '<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>',
  1590. name: 'map_attr',
  1591. value: newMapData.attribution,
  1592. width: 540,
  1593. },{
  1594. xtype: 'textarea',
  1595. fieldLabel: '<?=$Labels->GetLabel('_DESCRIPTION_');?>',
  1596. name: 'map_desc',
  1597. value: newMapData.desc,
  1598. width: 540,
  1599. },{
  1600. xtype: 'combo',
  1601. fieldLabel: '<?=$Labels->GetLabel('_MAX_ZOOM_');?>',
  1602. editable: false,
  1603. typeAhead: true,
  1604. name: 'map_maxz',
  1605. value: newMapData.maxZoom,
  1606. triggerAction: 'all',
  1607. width: 100,
  1608. lazyRender:true,
  1609. mode: 'local',
  1610. store: new Ext.data.ArrayStore({
  1611. fields: ['zoom_l'],
  1612. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1613. }),
  1614. value: '16',
  1615. valueField: 'zoom_l',
  1616. displayField: 'zoom_l'
  1617. },{
  1618. xtype: 'combo',
  1619. fieldLabel: '<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>',
  1620. editable: false,
  1621. typeAhead: true,
  1622. name: 'map_maxnz',
  1623. value: newMapData.maxNativeZoom,
  1624. triggerAction: 'all',
  1625. width: 100,
  1626. lazyRender:true,
  1627. mode: 'local',
  1628. store: new Ext.data.ArrayStore({
  1629. fields: ['zoom_l'],
  1630. data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
  1631. }),
  1632. value: '16',
  1633. valueField: 'zoom_l',
  1634. displayField: 'zoom_l'
  1635. },{
  1636. xtype: 'numberfield',
  1637. fieldLabel: '<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>',
  1638. name: 'map_tpb',
  1639. value: newMapData.img_tb,
  1640. width: 540,
  1641. },{
  1642. xtype: 'numberfield',
  1643. fieldLabel: '<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>',
  1644. name: 'map_lpb',
  1645. value: newMapData.img_lb,
  1646. width: 540,
  1647. },{
  1648. xtype: 'numberfield',
  1649. fieldLabel: '<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>',
  1650. name: 'map_rpb',
  1651. value: newMapData.img_rb,
  1652. width: 540,
  1653. },{
  1654. xtype: 'numberfield',
  1655. fieldLabel: '<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>',
  1656. name: 'map_bpb',
  1657. value: newMapData.img_bb,
  1658. width: 540,
  1659. },{
  1660. xtype: 'numberfield',
  1661. fieldLabel: '<?=$Labels->GetLabel('_MAP_WIDTH_');?>',
  1662. name: 'map_width',
  1663. decimalPrecision: 2,
  1664. value: newMapData.img_map_w,
  1665. width: 540,
  1666. },{
  1667. xtype: 'numberfield',
  1668. fieldLabel: '<?=$Labels->GetLabel('_MAP_HEIGHT_');?>',
  1669. name: 'map_height',
  1670. decimalPrecision: 2,
  1671. value: newMapData.img_map_h,
  1672. width: 540,
  1673. },{
  1674. xtype: 'panel',
  1675. frame: false,
  1676. border: false,
  1677. layout: 'table',
  1678. layoutConfig: {
  1679. columns: 5
  1680. },
  1681. items:[{
  1682. xtype: 'spacer',
  1683. width: 250,
  1684. html: '<p style="text-align:right; margin-right: 5px;"><?=$Labels->GetLabel('_MAP_CENTER_MODE_');?>:</p>'
  1685. },{
  1686. xtype: 'radio',
  1687. name: 'bounds_mode',
  1688. value: 0,
  1689. checked: ( newMapData.bounds_mode == 0 ),
  1690. fieldLabel: '',
  1691. },{
  1692. width: 80,
  1693. html: '<img src="/style/assets/cust_map_cord_sys-0.png">'
  1694. },{
  1695. xtype: 'radio',
  1696. name: 'bounds_mode',
  1697. checked: ( newMapData.bounds_mode == 1 ),
  1698. value: 1,
  1699. fieldLabel: '',
  1700. },{
  1701. html: '<img src="/style/assets/cust_map_cord_sys-1.png">'
  1702. }]
  1703. }]
  1704. }],
  1705. bbar:[ '->',{
  1706. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  1707. handler: function(){
  1708. mapEditorWindow.destroy();
  1709. }
  1710. },{
  1711. text: '<?=$Labels->GetLabel('_APPLY_CHANGES_');?>',
  1712. handler: function(){
  1713. if( Ext.getCmp('map_edt_frm').getForm().isValid()){
  1714. Ext.getCmp('map_edt_frm').getForm().submit({
  1715. url: '/lib/controller/updateMap.php',
  1716. waitMsg: 'Uploading Image...',
  1717. encoding: 'multipart/form-data',
  1718. success: function(fp, o){
  1719. //msg('Success', 'Processed file "'+o.result.file+'" on the server');
  1720. alert('Processed file on the server');
  1721. }
  1722. });
  1723. };
  1724. }
  1725. }],
  1726. listeners: {
  1727. beforedestroy: function(){
  1728. mapEditorWindow = null;
  1729. }
  1730. }
  1731. });
  1732. break;
  1733. };
  1734. };
  1735. };
  1736. mapEditorWindow.show();
  1737. },
  1738. failure: failureAJAXFunction
  1739. });
  1740. };