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.

782 lines
31 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var ActiveZones = null;
  3. var map = null;
  4. var map_ed = null;
  5. var markers = [];
  6. var selectedMarkerIcon = L.icon({
  7. iconUrl: '/style/assets/cursor.png',
  8. iconSize: [32, 32],
  9. iconAnchor: [16, 16]//,
  10. //popupAnchor: [-3, -76],
  11. //shadowUrl: 'my-icon-shadow.png',
  12. //shadowSize: [68, 95],
  13. //shadowAnchor: [22, 94]
  14. });
  15. selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
  16. function getZoneByNode( nid ){
  17. var rVal = -1;
  18. for( var i=0; i < ActiveZones.totalCount; i++ ){
  19. if( ActiveZones.zones[i].dev_id == nid ){
  20. rVal = i;
  21. break;
  22. };
  23. };
  24. return rVal;
  25. };
  26. function turnOffAllGzButThis( nid ){
  27. var chocho = -1;
  28. for( var i=0; i < ActiveZones.totalCount; i++ ){
  29. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  30. map.removeLayer( ActiveZones.fig[i] );
  31. map.removeLayer( ActiveZones.zang[i] );
  32. map.removeLayer( ActiveZones.center[i] );
  33. };
  34. if( chocho > -1 ){
  35. map.addLayer( ActiveZones.fig[chocho] );
  36. map.addLayer( ActiveZones.zang[chocho] );
  37. map.addLayer( ActiveZones.center[chocho] );
  38. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  39. map.flyToBounds( cVisible.getBounds() );
  40. };
  41. };
  42. function turnAllGzOn(){
  43. var tall = Array();
  44. for( var i=0; i < ActiveZones.totalCount; i++ ){
  45. tall[i*3] = ActiveZones.fig[i];
  46. tall[i*3+1] = ActiveZones.zang[i];
  47. tall[i*3+2] = ActiveZones.center[i];
  48. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  49. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  50. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  51. };
  52. var cVisible = L.featureGroup( tall );
  53. map.flyToBounds( cVisible.getBounds() );
  54. };
  55. function loadMapZones( SID ){
  56. Ext.Ajax.request({
  57. url: '/lib/controller/getGeoZones.php',
  58. params: {
  59. SITE: SID,
  60. UID: <?=$UserID;?>,
  61. SID: '<?=$Session;?>'
  62. },
  63. success: function( response, opts ){
  64. // If the response is JSON, you have to decode it
  65. var data = Ext.decode(response.responseText);
  66. var pp = Ext.getCmp('sources_panel');
  67. if( typeof pp !== 'undefined' ) pp.removeAll();
  68. ActiveZones = data;
  69. ActiveZones.fig = new Array();
  70. ActiveZones.zang = new Array();
  71. ActiveZones.center = new Array();
  72. for(var i = 0; i < data.totalCount; i++ ) {
  73. switch( data.zones[i].type ){
  74. case 'circle':{
  75. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  76. 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 } );
  77. //map.addLayer( ActiveZones.fig[i] );
  78. break;
  79. };
  80. case 'poly':{
  81. 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);
  82. //map.addLayer( ActiveZones.fig[i] );
  83. break;
  84. };
  85. case 'image':{
  86. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  87. //map.addLayer( ActiveZones.fig[i] );
  88. break;
  89. };
  90. case 'image_rot':{
  91. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  92. opacity: 0.8 //,
  93. //interactive: true,
  94. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geogr?fico Nacional de Espa?a</a>"
  95. });//.addTo( map );
  96. //map.addLayer( ActiveZones.fig[i] );
  97. break;
  98. };
  99. };
  100. if( data.zones[i].dev_is_source ){
  101. if( typeof pp !== 'undefined' ) {
  102. var sty = '';
  103. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  104. sty = 'cardDeviceSourceSelected';
  105. } else {
  106. sty = 'cardDeviceSource';
  107. };
  108. pp.add( {
  109. id: data.zones[i].dev_id+'_container',
  110. frame: false,
  111. border: false,
  112. width: 130,
  113. height: 130,
  114. 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>'
  115. });
  116. };
  117. };
  118. if( data.zones[i].zang != undefined ){
  119. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  120. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  121. };
  122. if( data.zones[i].center != undefined ){
  123. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  124. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  125. };
  126. };
  127. if( selecredActiveSourceFilter == 0 ){
  128. turnAllGzOn();
  129. } else {
  130. turnOffAllGzButThis( selecredActiveSourceFilter );
  131. };
  132. if( typeof pp !== 'undefined' ) pp.doLayout();
  133. //LoadMapEvents( SelectedSite );
  134. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  135. },
  136. failure: function( response, opts ) {
  137. //Ext.fly('some_div').update('Fail!');
  138. }
  139. });
  140. };
  141. var cevt = Array();
  142. var coz = Array();
  143. function showEventsOnMap( data, removeCursor ){
  144. if( removeCursor == undefined ) removeCursor = true;
  145. if( removeCursor ) map.removeLayer( selectedMarker );
  146. if( cevt.length ){
  147. for( i=0; i< cevt.length; i++ ){
  148. if( cevt[i]!= null ){
  149. cevt[i].remove();
  150. delete( cevt[i] );
  151. cevt[i] = null;
  152. };
  153. };
  154. };
  155. if( coz.length ){
  156. for( i=0; i< coz.length; i++ ){
  157. if( coz[i]!= null ){
  158. coz[i].remove();
  159. delete( coz[i] );
  160. coz[i]=null;
  161. };
  162. };
  163. };
  164. var idx = 0;
  165. for( i=0; i < data.length; i++ ){
  166. if( data[i].targets != undefined ){
  167. var zz = ( 1.0 / ( data[i].targets.length + 0 ) );
  168. var cp_color='#FF0000';
  169. for( j = 0; j < data[i].targets.length; j++ ){
  170. //switch( data.log[i].event ){
  171. // case 36: cp_color='#0000FF'; break;
  172. //};
  173. cLon = data[i].targets[j].lat;
  174. cLat = data[i].targets[j].lon;
  175. 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 ){
  176. // loadEventPropertiesByID( this.options.id );
  177. //} );
  178. cevt[idx].addTo(map);
  179. idx++;
  180. };
  181. };
  182. };
  183. };
  184. function LoadMapEventsZ( Mode ){
  185. if( tlLoadLocker ) return;
  186. tlLoadLocker = true;
  187. Ext.Ajax.request({
  188. url: '/lib/controller/getGeoAlerts.php',
  189. params: {
  190. SITE: <?=$SiteID;?>,
  191. UID: <?=$UserID;?>,
  192. SID: '<?=$Session;?>',
  193. MODE: Mode
  194. },
  195. success: function( response, opts ){
  196. if( cevt.length ){
  197. for( i=0; i< cevt.length; i++ ){
  198. if( cevt[i]!= null ){
  199. cevt[i].remove();
  200. delete( cevt[i] );
  201. cevt[i] = null;
  202. };
  203. };
  204. };
  205. if( coz.length ){
  206. for( i=0; i< coz.length; i++ ){
  207. if( coz[i]!= null ){
  208. coz[i].remove();
  209. delete( coz[i] );
  210. coz[i]=null;
  211. };
  212. };
  213. };
  214. var data = Ext.decode( response.responseText );
  215. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  216. for( i=0; i < data.evt.length; i++ ){
  217. 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 ){
  218. loadEventProperties( this.options.id );
  219. } );
  220. cevt[i].addTo(map);
  221. };
  222. for( i=0; i < data.other.length; i++ ){
  223. switch( data.other[i].type ){
  224. case 'circle':{
  225. 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 } );
  226. coz[i].addTo(map);
  227. break;
  228. };
  229. };
  230. };
  231. //eventsListStore.reload();
  232. tlLoadLocker = false;
  233. },
  234. failure: function( response, opts ) {
  235. //Ext.fly('some_div').update('Fail!');
  236. tlLoadLocker = false;
  237. }
  238. });
  239. };
  240. function initMapMonitoring(){
  241. map = L.map('event_map',{
  242. attributionControl: true,
  243. //preferCanvas: true,
  244. zoomControl: true,
  245. center: [SiteLat, SiteLon],
  246. /*zoomControl: false,
  247. zoom: 17,
  248. minZoom: 17,
  249. maxZoom: 17,*/
  250. keyboard: false
  251. }).setView([SiteLat, SiteLon], 17);
  252. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  253. var mapLayers = [];
  254. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  255. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  256. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  257. detectRetina: true
  258. });*/
  259. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  260. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  261. maxNativeZoom: 18,
  262. maxZoom: 24,
  263. })
  264. // https://leaflet-extras.github.io/leaflet-providers/preview/
  265. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  266. 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',
  267. maxZoom: 19
  268. });
  269. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  270. 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',
  271. maxZoom: 19
  272. });
  273. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  274. 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',
  275. maxZoom: 24
  276. });
  277. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  278. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  279. maxZoom: 19
  280. });
  281. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  282. 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>) ',
  283. maxZoom: 19
  284. });
  285. /*
  286. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  287. 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>',
  288. maxZoom: 22
  289. });
  290. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  291. 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>',
  292. maxZoom: 22
  293. });
  294. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  295. 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>',
  296. maxZoom: 22
  297. });
  298. */
  299. var baseMaps = {
  300. "MyMap": mapLayers["MyMap"],
  301. "OpenStreetMap": mapLayers["OpenStreetMap"],
  302. "OpenTopoMap": mapLayers["OpenTopoMap"],
  303. "EsriSat": mapLayers["EsriSat"],
  304. "EsriStreet": mapLayers["EsriStreet"],
  305. "EsriTopo": mapLayers["EsriTopo"],
  306. //"Bing": mapLayers["Bing"],
  307. //"OSM-Cycle": mapLayers["Cycle"],
  308. //"Landscape": mapLayers["Landscape"],
  309. //"Outdoor": mapLayers["Outdoor"],
  310. };
  311. L.control.layers( baseMaps ).addTo(map);
  312. mapLayers["MyMap"].addTo(map);
  313. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  314. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  315. maxNativeZoom: 18,
  316. maxZoom: 24,
  317. }).addTo(map); */
  318. //loadTimeLineGroups( selectedSite );
  319. loadMapZones( 0 );
  320. //getData( 'arch' );
  321. };
  322. var iconSaver = null;
  323. var markerSaver = null;
  324. function updateLocation( e ){
  325. locationSelectedNode = e.target.options.mycustomid;
  326. Ext.Ajax.request({
  327. url: '/lib/controller/updateLocation.php',
  328. params: {
  329. NODE: locationSelectedNode,
  330. SITE: <?=$SiteID;?>,
  331. UID: <?=$UserID;?>,
  332. TYPE: 0,
  333. SID: '<?=$Session;?>',
  334. LAT: e.target._latlng.lat,
  335. LON: e.target._latlng.lng
  336. },
  337. success: function( response, opts ){
  338. loadNodeLocationProps( locationSelectedNode );
  339. },
  340. failure: failureAJAXFunction
  341. });
  342. };
  343. function markerDblClick( e ){
  344. if( iconSaver == null ){
  345. iconSaver = e.target.options.icon;
  346. markerSaver = e.target;
  347. e.target.setIcon( SNAPE_Icon );
  348. for( i=0; i< markers.length; i++){
  349. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  350. markers[i].setOpacity( 0.1 );
  351. } else {
  352. markers[i].setOpacity( 1.0 );
  353. }
  354. };
  355. } else {
  356. if( e.target.options.mycustomid == markerSaver.options.mycustomid ){
  357. e.target.setIcon( iconSaver );
  358. iconSaver = null;
  359. markerSaver = null;
  360. for( i=0; i< markers.length; i++){
  361. markers[i].setOpacity( 1.0 );
  362. };
  363. } else {
  364. markerSaver.setIcon( iconSaver );
  365. iconSaver = e.target.options.icon;
  366. markerSaver = e.target;
  367. e.target.setIcon( SNAPE_Icon );
  368. for( i=0; i< markers.length; i++){
  369. if( markers[i].options.mycustomid != e.target.options.mycustomid ){
  370. markers[i].setOpacity( 0.1 );
  371. } else {
  372. markers[i].setOpacity( 1.0 );
  373. }
  374. };
  375. };
  376. };
  377. };
  378. function setNodeLocationToAnchor(){
  379. Ext.Ajax.request({
  380. url: '/lib/controller/updateLocation.php',
  381. params: {
  382. NODE: locationSelectedNode,
  383. SITE: <?=$SiteID;?>,
  384. UID: <?=$UserID;?>,
  385. TYPE: 0,
  386. SID: '<?=$Session;?>',
  387. LAT: SiteLat,
  388. LON: SiteLon,
  389. ALT: SiteAlt
  390. },
  391. success: function( response, opts ){
  392. loadLocationEditor();
  393. },
  394. failure: failureAJAXFunction
  395. });
  396. };
  397. function setNodeLocationByDelta(){
  398. var dx = Ext.getCmp('dx').getValue();
  399. var dy = Ext.getCmp('dy').getValue();
  400. var dz = Ext.getCmp('dz').getValue();
  401. Ext.Ajax.request({
  402. url: '/lib/controller/updateLocation.php',
  403. params: {
  404. NODE: locationSelectedNode,
  405. SITE: <?=$SiteID;?>,
  406. UID: <?=$UserID;?>,
  407. TYPE: 3,
  408. SID: '<?=$Session;?>',
  409. LAT: dx,
  410. LON: dy,
  411. ALT: dz
  412. },
  413. success: function( response, opts ){
  414. loadLocationEditor();
  415. },
  416. failure: failureAJAXFunction
  417. });
  418. };
  419. var LRF3D_Icon = L.icon({
  420. iconUrl: '/style/assets/5_node.png',
  421. //shadowUrl: 'leaf-shadow.png',
  422. iconSize: [64, 64], // size of the icon
  423. //shadowSize: [50, 64], // size of the shadow
  424. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  425. //shadowAnchor: [4, 62], // the same for the shadow
  426. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  427. });
  428. var LFS_Icon = L.icon({
  429. iconUrl: '/style/assets/2_node.png',
  430. //shadowUrl: 'leaf-shadow.png',
  431. iconSize: [64, 64], // size of the icon
  432. //shadowSize: [50, 64], // size of the shadow
  433. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  434. //shadowAnchor: [4, 62], // the same for the shadow
  435. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  436. });
  437. var PLS200_Icon = L.icon({
  438. iconUrl: '/style/assets/3_node.png',
  439. //shadowUrl: 'leaf-shadow.png',
  440. iconSize: [64, 64], // size of the icon
  441. //shadowSize: [50, 64], // size of the shadow
  442. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  443. //shadowAnchor: [4, 62], // the same for the shadow
  444. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  445. });
  446. var PLSNET200_Icon = L.icon({
  447. iconUrl: '/style/assets/6_node.png',
  448. //shadowUrl: 'leaf-shadow.png',
  449. iconSize: [64, 64], // size of the icon
  450. //shadowSize: [50, 64], // size of the shadow
  451. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  452. //shadowAnchor: [4, 62], // the same for the shadow
  453. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  454. });
  455. var PLS360_Icon = L.icon({
  456. iconUrl: '/style/assets/4_node.png',
  457. //shadowUrl: 'leaf-shadow.png',
  458. iconSize: [64, 64], // size of the icon
  459. //shadowSize: [50, 64], // size of the shadow
  460. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  461. //shadowAnchor: [4, 62], // the same for the shadow
  462. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  463. });
  464. var ALS_Icon = L.icon({
  465. iconUrl: '/style/assets/1_node.png',
  466. //shadowUrl: 'leaf-shadow.png',
  467. iconSize: [64, 64], // size of the icon
  468. //shadowSize: [50, 64], // size of the shadow
  469. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  470. //shadowAnchor: [4, 62], // the same for the shadow
  471. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  472. });
  473. var PTZCAM_Icon = L.icon({
  474. iconUrl: '/style/assets/12_node.png',
  475. //shadowUrl: 'leaf-shadow.png',
  476. iconSize: [64, 64], // size of the icon
  477. //shadowSize: [50, 64], // size of the shadow
  478. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  479. //shadowAnchor: [4, 62], // the same for the shadow
  480. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  481. });
  482. var FIXCAM_Icon = L.icon({
  483. iconUrl: '/style/assets/11_node.png',
  484. //shadowUrl: 'leaf-shadow.png',
  485. iconSize: [64, 64], // size of the icon
  486. //shadowSize: [50, 64], // size of the shadow
  487. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  488. //shadowAnchor: [4, 62], // the same for the shadow
  489. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  490. });
  491. var SITEZ_Icon = L.icon({
  492. iconUrl: '/style/assets/centre_1.png',
  493. //shadowUrl: 'leaf-shadow.png',
  494. iconSize: [32, 32], // size of the icon
  495. //shadowSize: [50, 64], // size of the shadow
  496. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  497. //shadowAnchor: [4, 62], // the same for the shadow
  498. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  499. });
  500. var SNAPE_Icon = L.icon({
  501. iconUrl: '/style/assets/cursor.png',
  502. //shadowUrl: 'leaf-shadow.png',
  503. iconSize: [32, 32], // size of the icon
  504. //shadowSize: [50, 64], // size of the shadow
  505. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  506. //shadowAnchor: [4, 62], // the same for the shadow
  507. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  508. });
  509. function loadLocationNodes(){
  510. Ext.Ajax.request({
  511. url: '/lib/controller/getLocationItems.php',
  512. params: {
  513. SITE: <?=$SiteID;?>,
  514. UID: <?=$UserID;?>,
  515. SID: '<?=$Session;?>'
  516. },
  517. success: function( response, opts ){
  518. var data = Ext.decode(response.responseText);
  519. for( i=0; i < data.length; i++){
  520. switch( data[i].type ){
  521. case 1:{
  522. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  523. break;
  524. };
  525. case 2:{
  526. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LFS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  527. break;
  528. };
  529. case 3:{
  530. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  531. break;
  532. };
  533. case 4:{
  534. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS360_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  535. break;
  536. };
  537. case 5:{
  538. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LRF3D_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  539. break;
  540. };
  541. case 6:{
  542. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLSNET200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  543. break;
  544. };
  545. case 10:
  546. case 12:{
  547. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: FIXCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  548. break;
  549. };
  550. case 11:
  551. case 13:{
  552. markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PTZCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
  553. break;
  554. };
  555. };
  556. //bindPopup('A pretty CSS3 popup.<br> Easily customizable.');//.openPopup();
  557. };
  558. },
  559. failure: function( response, opts ) {
  560. var tPanel = Ext.getCmp('main_portal');
  561. tPanel.remove(0);
  562. tPanel.add( { html: 'Failed to load dashboard!' } );
  563. tPanel.doLayout();
  564. }
  565. });
  566. };
  567. function loadNodeLocationProps( NodeID ){
  568. //alert( 'Node: ' + NodeID );
  569. Ext.Ajax.request({
  570. url: '/lib/controller/getLocationNodeProps.php',
  571. params: {
  572. NID: <?=$SiteID;?>,
  573. UID: <?=$UserID;?>,
  574. SID: '<?=$Session;?>',
  575. NODE: NodeID
  576. },
  577. success: function( response, opts ){
  578. // If the response is JSON, you have to decode it
  579. var data = Ext.decode(response.responseText);
  580. var tPanel = Ext.getCmp('prop_content');
  581. tPanel.remove(0);
  582. tPanel.add( data );
  583. tPanel.doLayout();
  584. },
  585. failure: failureAJAXFunction
  586. });
  587. };
  588. function LoadNodesList(){
  589. Ext.Ajax.request({
  590. url: '/lib/controller/getLocationNodes.php',
  591. params: {
  592. SITE: <?=$SiteID;?>,
  593. UID: <?=$UserID;?>,
  594. SID: '<?=$Session;?>'
  595. },
  596. success: function( response, opts ){
  597. // If the response is JSON, you have to decode it
  598. var data = Ext.decode(response.responseText);
  599. var tPanel = Ext.getCmp('prop_content');
  600. tPanel.remove(0);
  601. tPanel.add( data );
  602. tPanel.doLayout();
  603. },
  604. failure: failureAJAXFunction
  605. });
  606. };
  607. function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
  608. if( tlInterval!= null ){
  609. window.clearInterval( tlInterval );
  610. tlInterval = null;
  611. timelineObj = null;
  612. };
  613. if( node_type == undefined ) node_type = 0;
  614. if( lat == undefined ){
  615. lat = SiteLat;
  616. lon = SiteLon;
  617. };
  618. map_ed = L.map( el_id,{
  619. attributionControl: true,
  620. //preferCanvas: true,
  621. zoomControl: true,
  622. center: [SiteLat, SiteLon],
  623. /*zoomControl: false,
  624. zoom: 17,
  625. minZoom: 17,
  626. maxZoom: 17,*/
  627. keyboard: false
  628. }).setView([SiteLat, SiteLon], 17);
  629. 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();
  630. var mapLayers = [];
  631. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  632. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  633. maxNativeZoom: 18,
  634. maxZoom: 24,
  635. })
  636. // https://leaflet-extras.github.io/leaflet-providers/preview/
  637. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  638. 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',
  639. maxZoom: 19
  640. });
  641. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  642. 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',
  643. maxZoom: 19
  644. });
  645. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  646. 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',
  647. maxZoom: 24
  648. });
  649. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  650. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  651. maxZoom: 19
  652. });
  653. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  654. 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>) ',
  655. maxZoom: 19
  656. });
  657. /*
  658. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  659. 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>',
  660. maxZoom: 22
  661. });
  662. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  663. 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>',
  664. maxZoom: 22
  665. });
  666. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  667. 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>',
  668. maxZoom: 22
  669. });
  670. */
  671. var baseMaps = {
  672. "MyMap": mapLayers["MyMap"],
  673. "OpenStreetMap": mapLayers["OpenStreetMap"],
  674. "OpenTopoMap": mapLayers["OpenTopoMap"],
  675. "EsriSat": mapLayers["EsriSat"],
  676. "EsriStreet": mapLayers["EsriStreet"],
  677. "EsriTopo": mapLayers["EsriTopo"],
  678. //"Bing": mapLayers["Bing"],
  679. //"OSM-Cycle": mapLayers["Cycle"],
  680. //"Landscape": mapLayers["Landscape"],
  681. //"Outdoor": mapLayers["Outdoor"],
  682. };
  683. L.control.layers( baseMaps ).addTo( map_ed );
  684. mapLayers["MyMap"].addTo( map_ed );
  685. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  686. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  687. }).addTo( map_ed );
  688. if( node_type ){
  689. switch( node_type ){
  690. case 1:{
  691. 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 );
  692. break;
  693. };
  694. case 2:{
  695. 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 );
  696. break;
  697. };
  698. case 3:{
  699. 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 );
  700. break;
  701. };
  702. case 4:{
  703. 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 );
  704. break;
  705. };
  706. case 5:{
  707. 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 );
  708. break;
  709. };
  710. case 6:{
  711. 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 );
  712. break;
  713. };
  714. case 10:
  715. case 12:{
  716. 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 );
  717. break;
  718. };
  719. case 11:
  720. case 13:{
  721. 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 );
  722. break;
  723. };
  724. };
  725. };
  726. //loadLocationNodes();
  727. };