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.

326 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var ActiveZones = null;
  3. function getZoneByNode( nid ){
  4. var rVal = -1;
  5. for( var i=0; i < ActiveZones.totalCount; i++ ){
  6. if( ActiveZones.zones[i].dev_id == nid ){
  7. rVal = i;
  8. break;
  9. };
  10. };
  11. return rVal;
  12. };
  13. function turnOffAllGzButThis( nid ){
  14. var chocho = -1;
  15. for( var i=0; i < ActiveZones.totalCount; i++ ){
  16. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  17. map.removeLayer( ActiveZones.fig[i] );
  18. map.removeLayer( ActiveZones.zang[i] );
  19. map.removeLayer( ActiveZones.center[i] );
  20. };
  21. if( chocho > -1 ){
  22. map.addLayer( ActiveZones.fig[chocho] );
  23. map.addLayer( ActiveZones.zang[chocho] );
  24. map.addLayer( ActiveZones.center[chocho] );
  25. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  26. map.flyToBounds( cVisible.getBounds() );
  27. };
  28. };
  29. function turnAllGzOn(){
  30. var tall = Array();
  31. for( var i=0; i < ActiveZones.totalCount; i++ ){
  32. tall[i*3] = ActiveZones.fig[i];
  33. tall[i*3+1] = ActiveZones.zang[i];
  34. tall[i*3+2] = ActiveZones.center[i];
  35. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  36. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  37. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  38. };
  39. var cVisible = L.featureGroup( tall );
  40. map.flyToBounds( cVisible.getBounds() );
  41. };
  42. function loadMapZones( SID ){
  43. Ext.Ajax.request({
  44. url: '/lib/controller/getGeoZones.php',
  45. params: {
  46. SITE: SID,
  47. UID: <?=$UserID;?>,
  48. SID: '<?=$Session;?>'
  49. },
  50. success: function( response, opts ){
  51. // If the response is JSON, you have to decode it
  52. var data = Ext.decode(response.responseText);
  53. var pp = Ext.getCmp('sources_panel');
  54. if( typeof pp !== 'undefined' ) pp.removeAll();
  55. ActiveZones = data;
  56. ActiveZones.fig = new Array();
  57. ActiveZones.zang = new Array();
  58. ActiveZones.center = new Array();
  59. for(var i = 0; i < data.totalCount; i++ ) {
  60. switch( data.zones[i].type ){
  61. case 'circle':{
  62. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  63. 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 } );
  64. //map.addLayer( ActiveZones.fig[i] );
  65. break;
  66. };
  67. case 'poly':{
  68. 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);
  69. //map.addLayer( ActiveZones.fig[i] );
  70. break;
  71. };
  72. case 'image':{
  73. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  74. //map.addLayer( ActiveZones.fig[i] );
  75. break;
  76. };
  77. case 'image_rot':{
  78. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  79. opacity: 0.8 //,
  80. //interactive: true,
  81. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geogr?fico Nacional de Espa?a</a>"
  82. });//.addTo( map );
  83. //map.addLayer( ActiveZones.fig[i] );
  84. break;
  85. };
  86. };
  87. if( data.zones[i].dev_is_source ){
  88. if( typeof pp !== 'undefined' ) {
  89. var sty = '';
  90. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  91. sty = 'cardDeviceSourceSelected';
  92. } else {
  93. sty = 'cardDeviceSource';
  94. };
  95. pp.add( {
  96. id: data.zones[i].dev_id+'_container',
  97. frame: false,
  98. border: false,
  99. width: 130,
  100. height: 130,
  101. 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>'
  102. });
  103. };
  104. };
  105. if( data.zones[i].zang != undefined ){
  106. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  107. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  108. };
  109. if( data.zones[i].center != undefined ){
  110. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  111. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  112. };
  113. };
  114. if( selecredActiveSourceFilter == 0 ){
  115. turnAllGzOn();
  116. } else {
  117. turnOffAllGzButThis( selecredActiveSourceFilter );
  118. };
  119. if( typeof pp !== 'undefined' ) pp.doLayout();
  120. //LoadMapEvents( SelectedSite );
  121. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  122. },
  123. failure: function( response, opts ) {
  124. //Ext.fly('some_div').update('Fail!');
  125. }
  126. });
  127. };
  128. var cevt = Array();
  129. var coz = Array();
  130. function showEventsOnMap( data, removeCursor = true ){
  131. if( removeCursor ) map.removeLayer( selectedMarker );
  132. if( cevt.length ){
  133. for( i=0; i< cevt.length; i++ ){
  134. if( cevt[i]!= null ){
  135. cevt[i].remove();
  136. delete( cevt[i] );
  137. cevt[i] = null;
  138. };
  139. };
  140. };
  141. if( coz.length ){
  142. for( i=0; i< coz.length; i++ ){
  143. if( coz[i]!= null ){
  144. coz[i].remove();
  145. delete( coz[i] );
  146. coz[i]=null;
  147. };
  148. };
  149. };
  150. var zz = ( 1.0 / ( data.log.length + 0 ) );
  151. var idx = 0;
  152. for( i=0; i < data.log.length; i++ ){
  153. if( data.log[i].has_geo ){
  154. var cp_color='#FF0000';
  155. switch( data.log[i].event ){
  156. case 36: cp_color='#0000FF'; break;
  157. };
  158. cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  159. loadEventPropertiesByID( this.options.id );
  160. } );
  161. cevt[idx].addTo(map);
  162. idx++;
  163. };
  164. };
  165. };
  166. function LoadMapEventsZ( Mode ){
  167. if( tlLoadLocker ) return;
  168. tlLoadLocker = true;
  169. Ext.Ajax.request({
  170. url: '/lib/controller/getGeoAlerts.php',
  171. params: {
  172. SITE: <?=$SiteID;?>,
  173. UID: <?=$UserID;?>,
  174. SID: '<?=$Session;?>',
  175. MODE: Mode
  176. },
  177. success: function( response, opts ){
  178. if( cevt.length ){
  179. for( i=0; i< cevt.length; i++ ){
  180. if( cevt[i]!= null ){
  181. cevt[i].remove();
  182. delete( cevt[i] );
  183. cevt[i] = null;
  184. };
  185. };
  186. };
  187. if( coz.length ){
  188. for( i=0; i< coz.length; i++ ){
  189. if( coz[i]!= null ){
  190. coz[i].remove();
  191. delete( coz[i] );
  192. coz[i]=null;
  193. };
  194. };
  195. };
  196. var data = Ext.decode( response.responseText );
  197. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  198. for( i=0; i < data.evt.length; i++ ){
  199. 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 ){
  200. loadEventProperties( this.options.id );
  201. } );
  202. cevt[i].addTo(map);
  203. };
  204. for( i=0; i < data.other.length; i++ ){
  205. switch( data.other[i].type ){
  206. case 'circle':{
  207. 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 } );
  208. coz[i].addTo(map);
  209. break;
  210. };
  211. };
  212. };
  213. //eventsListStore.reload();
  214. tlLoadLocker = false;
  215. },
  216. failure: function( response, opts ) {
  217. //Ext.fly('some_div').update('Fail!');
  218. tlLoadLocker = false;
  219. }
  220. });
  221. };
  222. function initMapMonitoring(){
  223. map = L.map('event_map',{
  224. attributionControl: true,
  225. //preferCanvas: true,
  226. zoomControl: true,
  227. center: [SiteLat, SiteLon],
  228. /*zoomControl: false,
  229. zoom: 17,
  230. minZoom: 17,
  231. maxZoom: 17,*/
  232. keyboard: false
  233. }).setView([SiteLat, SiteLon], 17);
  234. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  235. var mapLayers = [];
  236. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  237. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  238. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  239. detectRetina: true
  240. });*/
  241. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  242. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  243. maxNativeZoom: 18,
  244. maxZoom: 24,
  245. })
  246. // https://leaflet-extras.github.io/leaflet-providers/preview/
  247. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  248. 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',
  249. maxZoom: 19
  250. });
  251. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  252. 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',
  253. maxZoom: 19
  254. });
  255. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  256. 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',
  257. maxZoom: 24
  258. });
  259. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  260. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  261. maxZoom: 19
  262. });
  263. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  264. 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>) ',
  265. maxZoom: 19
  266. });
  267. /*
  268. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  269. 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>',
  270. maxZoom: 22
  271. });
  272. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  273. 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>',
  274. maxZoom: 22
  275. });
  276. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  277. 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>',
  278. maxZoom: 22
  279. });
  280. */
  281. var baseMaps = {
  282. "MyMap": mapLayers["MyMap"],
  283. "OpenStreetMap": mapLayers["OpenStreetMap"],
  284. "OpenTopoMap": mapLayers["OpenTopoMap"],
  285. "EsriSat": mapLayers["EsriSat"],
  286. "EsriStreet": mapLayers["EsriStreet"],
  287. "EsriTopo": mapLayers["EsriTopo"],
  288. //"Bing": mapLayers["Bing"],
  289. //"OSM-Cycle": mapLayers["Cycle"],
  290. //"Landscape": mapLayers["Landscape"],
  291. //"Outdoor": mapLayers["Outdoor"],
  292. };
  293. L.control.layers( baseMaps ).addTo(map);
  294. mapLayers["MyMap"].addTo(map);
  295. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  296. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  297. maxNativeZoom: 18,
  298. maxZoom: 24,
  299. }).addTo(map); */
  300. //loadTimeLineGroups( selectedSite );
  301. loadMapZones( 0 );
  302. //getData( 'arch' );
  303. };