|
|
//<?php require_once('../../js_asm.php'); ?>
var ActiveZones = null;var map = null;var map_ed = null;var markers = [];
var selectedMarkerIcon = L.icon({ iconUrl: '/style/assets/cursor.png', iconSize: [32, 32], iconAnchor: [16, 16]//,
//popupAnchor: [-3, -76],
//shadowUrl: 'my-icon-shadow.png',
//shadowSize: [68, 95],
//shadowAnchor: [22, 94]
});
selectedMarker = L.marker([SiteLat, SiteLon], { draggable: false, icon: selectedMarkerIcon } );
function getZoneByNode( nid ){ var rVal = -1; for( var i=0; i < ActiveZones.totalCount; i++ ){ if( ActiveZones.zones[i].dev_id == nid ){ rVal = i; break; }; }; return rVal;};
function turnOffAllGzButThis( nid ){ var chocho = -1; for( var i=0; i < ActiveZones.totalCount; i++ ){ if( ActiveZones.zones[i].dev_id == nid ) chocho = i; map.removeLayer( ActiveZones.fig[i] ); map.removeLayer( ActiveZones.zang[i] ); map.removeLayer( ActiveZones.center[i] ); }; if( chocho > -1 ){ map.addLayer( ActiveZones.fig[chocho] ); map.addLayer( ActiveZones.zang[chocho] ); map.addLayer( ActiveZones.center[chocho] ); var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) ); map.flyToBounds( cVisible.getBounds() ); };};
function turnAllGzOn(){ var tall = Array(); for( var i=0; i < ActiveZones.totalCount; i++ ){ tall[i*3] = ActiveZones.fig[i]; tall[i*3+1] = ActiveZones.zang[i]; tall[i*3+2] = ActiveZones.center[i]; if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] ); if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] ); if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] ); }; var cVisible = L.featureGroup( tall ); map.flyToBounds( cVisible.getBounds() );};
function loadMapZones( SID ){ Ext.Ajax.request({ url: '/lib/controller/getGeoZones.php', params: { SITE: SID, UID: <?=$UserID;?>, SID: '<?=$Session;?>' }, success: function( response, opts ){ // If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText); var pp = Ext.getCmp('sources_panel'); if( typeof pp !== 'undefined' ) pp.removeAll(); ActiveZones = data; ActiveZones.fig = new Array(); ActiveZones.zang = new Array(); ActiveZones.center = new Array(); for(var i = 0; i < data.totalCount; i++ ) { switch( data.zones[i].type ){ case 'circle':{ //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
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 } ); //map.addLayer( ActiveZones.fig[i] );
break; }; case 'poly':{ 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);
//map.addLayer( ActiveZones.fig[i] );
break; }; case 'image':{ ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
//map.addLayer( ActiveZones.fig[i] );
break; }; case 'image_rot':{ ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, { opacity: 0.8 //,
//interactive: true,
//attribution: "Historical building plan © <a href='http://www.ign.es'>Instituto Geogr?fico Nacional de Espa?a</a>"
});//.addTo( map );
//map.addLayer( ActiveZones.fig[i] );
break; }; }; /* if( data.zones[i].dev_is_source ){ if( typeof pp !== 'undefined' ) { var sty = ''; if( selecredActiveSourceFilter == data.zones[i].dev_id ){ sty = 'cardDeviceSourceSelected'; } else { sty = 'cardDeviceSource'; }; pp.add( { id: data.zones[i].dev_id+'_container', frame: false, border: false, width: 130, height: 130, 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>' }); }; };*/ if( data.zones[i].zang != undefined ){ //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
}; if( data.zones[i].center != undefined ){ //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
}; }; //if( selecredActiveSourceFilter == 0 ){
turnAllGzOn(); //} else {
// turnOffAllGzButThis( selecredActiveSourceFilter );
//};
//if( typeof pp !== 'undefined' ) pp.doLayout();
}, failure: function( response, opts ) { //Ext.fly('some_div').update('Fail!');
} });};
var cevt = Array();var coz = Array();
function showEventsOnMap( data, removeCursor ){ if( removeCursor == undefined ) removeCursor = true; if( removeCursor ) map.removeLayer( selectedMarker ); if( cevt.length ){ for( i=0; i< cevt.length; i++ ){ if( cevt[i]!= null ){ cevt[i].remove(); delete( cevt[i] ); cevt[i] = null; }; }; }; if( coz.length ){ for( i=0; i< coz.length; i++ ){ if( coz[i]!= null ){ coz[i].remove(); delete( coz[i] ); coz[i]=null; }; }; }; var idx = 0; for( i=0; i < data.length; i++ ){ if( data[i].targets != undefined ){ var zz = ( 1.0 / ( data[i].targets.length + 0 ) ); var cp_color='#FF0000'; for( j = 0; j < data[i].targets.length; j++ ){ //switch( data.log[i].event ){
// case 36: cp_color='#0000FF'; break;
//};
cLon = data[i].targets[j].lat; cLat = data[i].targets[j].lon; 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 ){
// loadEventPropertiesByID( this.options.id );
//} );
cevt[idx].addTo(map); idx++; }; }; };};
function LoadMapEventsZ( Mode ){ if( tlLoadLocker ) return; tlLoadLocker = true; Ext.Ajax.request({ url: '/lib/controller/getGeoAlerts.php', params: { SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, SID: '<?=$Session;?>', MODE: Mode }, success: function( response, opts ){ if( cevt.length ){ for( i=0; i< cevt.length; i++ ){ if( cevt[i]!= null ){ cevt[i].remove(); delete( cevt[i] ); cevt[i] = null; }; }; }; if( coz.length ){ for( i=0; i< coz.length; i++ ){ if( coz[i]!= null ){ coz[i].remove(); delete( coz[i] ); coz[i]=null; }; }; }; var data = Ext.decode( response.responseText ); var zz = ( 1.0 / ( data.evt.length + 0 ) ); for( i=0; i < data.evt.length; i++ ){ 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 ){ loadEventProperties( this.options.id ); } ); cevt[i].addTo(map); }; for( i=0; i < data.other.length; i++ ){ switch( data.other[i].type ){ case 'circle':{ 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 } ); coz[i].addTo(map); break; }; }; }; //eventsListStore.reload();
tlLoadLocker = false; }, failure: function( response, opts ) { //Ext.fly('some_div').update('Fail!');
tlLoadLocker = false; } });};
function initMapMonitoring(){ map = L.map('event_map',{ attributionControl: true, //preferCanvas: true,
zoomControl: true, center: [SiteLat, SiteLon], /*zoomControl: false, zoom: 17, minZoom: 17, maxZoom: 17,*/ keyboard: false }).setView([SiteLat, SiteLon], 17); //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
var mapLayers = []; /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', { subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], attribution: '© <a href="https://bing.com/maps" target="_blank">Bing Maps</a>', detectRetina: true });*/ mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', maxNativeZoom: 18, maxZoom: 24, }) // https://leaflet-extras.github.io/leaflet-providers/preview/
mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012', maxZoom: 19 });
mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', maxZoom: 19 });
mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — 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', maxZoom: 24 });
mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
attribution: 'Map data © <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors', maxZoom: 19 });
mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", { attribution: 'Kartendaten: © <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: © <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>) ', maxZoom: 19 }); /* mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>', maxZoom: 22 }); mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>', maxZoom: 22 }); mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>', maxZoom: 22 }); */
var baseMaps = { "MyMap": mapLayers["MyMap"], "OpenStreetMap": mapLayers["OpenStreetMap"], "OpenTopoMap": mapLayers["OpenTopoMap"], "EsriSat": mapLayers["EsriSat"], "EsriStreet": mapLayers["EsriStreet"], "EsriTopo": mapLayers["EsriTopo"], //"Bing": mapLayers["Bing"],
//"OSM-Cycle": mapLayers["Cycle"],
//"Landscape": mapLayers["Landscape"],
//"Outdoor": mapLayers["Outdoor"],
}; L.control.layers( baseMaps ).addTo(map); mapLayers["MyMap"].addTo(map); /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', maxNativeZoom: 18, maxZoom: 24, }).addTo(map); */ //loadTimeLineGroups( selectedSite );
loadMapZones( 0 ); //getData( 'arch' );
};
var iconSaver = null;var markerSaver = null;
function updateLocation( e ){ locationSelectedNode = e.target.options.mycustomid; Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 0, SID: '<?=$Session;?>', LAT: e.target._latlng.lat, LON: e.target._latlng.lng }, success: function( response, opts ){ loadNodeLocationProps( locationSelectedNode ); }, failure: failureAJAXFunction });};
function markerDblClick( e ){ if( iconSaver == null ){ iconSaver = e.target.options.icon; markerSaver = e.target; e.target.setIcon( SNAPE_Icon ); for( i=0; i< markers.length; i++){ if( markers[i].options.mycustomid != e.target.options.mycustomid ){ markers[i].setOpacity( 0.1 ); } else { markers[i].setOpacity( 1.0 ); } }; } else { if( e.target.options.mycustomid == markerSaver.options.mycustomid ){ e.target.setIcon( iconSaver ); iconSaver = null; markerSaver = null; for( i=0; i< markers.length; i++){ markers[i].setOpacity( 1.0 ); }; } else { markerSaver.setIcon( iconSaver ); iconSaver = e.target.options.icon; markerSaver = e.target; e.target.setIcon( SNAPE_Icon ); for( i=0; i< markers.length; i++){ if( markers[i].options.mycustomid != e.target.options.mycustomid ){ markers[i].setOpacity( 0.1 ); } else { markers[i].setOpacity( 1.0 ); } }; }; };};
function setNodeLocationToAnchor(){ Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 0, SID: '<?=$Session;?>', LAT: SiteLat, LON: SiteLon, ALT: SiteAlt }, success: function( response, opts ){ loadLocationEditor(); }, failure: failureAJAXFunction });};
function setNodeLocationByDelta(){ var dx = Ext.getCmp('dx').getValue(); var dy = Ext.getCmp('dy').getValue(); var dz = Ext.getCmp('dz').getValue(); Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 3, SID: '<?=$Session;?>', LAT: dx, LON: dy, ALT: dz }, success: function( response, opts ){ loadLocationEditor(); }, failure: failureAJAXFunction });};
var LRF3D_Icon = L.icon({ iconUrl: '/style/assets/5_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var LFS_Icon = L.icon({ iconUrl: '/style/assets/2_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var PLS200_Icon = L.icon({ iconUrl: '/style/assets/3_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var PLSNET200_Icon = L.icon({ iconUrl: '/style/assets/6_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var PLS360_Icon = L.icon({ iconUrl: '/style/assets/4_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var ALS_Icon = L.icon({ iconUrl: '/style/assets/1_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var PTZCAM_Icon = L.icon({ iconUrl: '/style/assets/12_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var FIXCAM_Icon = L.icon({ iconUrl: '/style/assets/11_node.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [64, 64], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
});
var SITEZ_Icon = L.icon({ iconUrl: '/style/assets/centre_1.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [32, 32], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
});
var SNAPE_Icon = L.icon({ iconUrl: '/style/assets/cursor.png', //shadowUrl: 'leaf-shadow.png',
iconSize: [32, 32], // size of the icon
//shadowSize: [50, 64], // size of the shadow
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
//shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
});
function loadLocationNodes(){ Ext.Ajax.request({ url: '/lib/controller/getLocationItems.php', params: { SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, SID: '<?=$Session;?>' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); for( i=0; i < data.length; i++){ switch( data[i].type ){ case 1:{ 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 ); break; }; case 2:{ 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 ); break; }; case 3:{ 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 ); break; }; case 4:{ 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 ); break; }; case 5:{ 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 ); break; }; case 6:{ 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 ); break; }; case 10: case 12:{ 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 ); break; }; case 11: case 13:{ 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 ); break; }; }; //bindPopup('A pretty CSS3 popup.<br> Easily customizable.');//.openPopup();
}; }, failure: function( response, opts ) { //var tPanel = Ext.getCmp('main_portal');
//tPanel.remove(0);
//tPanel.add( { html: 'Failed to load dashboard!' } );
//tPanel.doLayout();
} });};
function orientationEditor(){ if( orientationEditorWindow == null ){ orientationEditorWindow = new Ext.Window({ modal: true, title: 'Orientation', closeAction: 'hide', width: 640, height: 500, items:[{ layout: 'table', defaults: { bodyStyle:'padding:5px' }, layoutConfig: { columns: 3 }, items:[{ html: 'Roll:' },{ xtype: 'textfield', id: 'roll', name: 'roll', value: 30.0029, listeners:{ change: function( sl, nv, tt ){ setCubeOrientation( nv / 1.0, curY, curZ ); } } },{ xtype: 'slider', id: 'roll_sld', width: 200, value: 30.0029, minValue: -180.0, maxValue: 180.0, listeners:{ change: function( sl, nv, tt ){ setCubeOrientation( nv, curY, curZ ); } } },{ html: 'Pitch:' },{ xtype: 'textfield', id: 'pitch', name: 'pitch', value: 30.0029, listeners:{ change: function( sl, nv, tt ){ setCubeOrientation( curX, nv / 1.0, curZ ); } } },{ xtype: 'slider', id: 'pitch_sld', width: 200, value: 30.0029, minValue: -180.0, maxValue: 180.0, listeners:{ change: function( sl, nv, tt ){ setCubeOrientation( curX, nv, curZ ); } } },{ html: 'Yaw:' },{ xtype: 'textfield', id: 'yaw', name: 'yaw', value: 30.0029, listeners:{ change: function( sl, nv, tt ){ //alert( nv );
setCubeOrientation( curX, curY, nv / 1.0 ); } } },{ xtype: 'slider', id: 'yaw_sld', width: 200, value: 30.0029, minValue: -180.0, maxValue: 180.0, listeners:{ change: function( sl, nv, tt ){ setCubeOrientation( curX, curY, nv ); } } }] },{ 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>' }], buttons:[{ text: 'Cancel', width: 200, handler: function(){ orientationEditorWindow.hide(); } },{ text: 'Apply', width: 200, handler: function(){ Ext.getCmp('sroll').setValue( Ext.getCmp('roll').getValue() ); Ext.getCmp('spitch').setValue( Ext.getCmp('pitch').getValue() ); Ext.getCmp('syaw').setValue( Ext.getCmp('yaw').getValue() ); orientationEditorWindow.hide(); } }] });
orientationEditorWindow.show();
cubeViewport = new Viewport({ element: document.getElementsByClassName('cube')[0], fps: 20, sensivity: .1, sensivityFade: .93, speed: 2, touchSensivity: 1.5 });
cube = new Cube({ viewport: cubeViewport, element: document.getElementsByClassName('cube')[0] }); } else { orientationEditorWindow.show(); }; setCubeOrientation( Ext.getCmp('sroll').getValue(), Ext.getCmp('spitch').getValue(), Ext.getCmp('syaw').getValue() );};
var locationSelectedNode = 0;function loadLoactionProps( e ){ if( typeof e == 'number' ){ locationSelectedNode = e; } else { locationSelectedNode = e.sourceTarget.options.mycustomid; } loadNodeLocationProps( locationSelectedNode );};
function loadNodeLocationProps( NodeID ){ //alert( 'Node: ' + NodeID );
Ext.Ajax.request({ url: '/lib/controller/getLocationNodeProps.php', params: { NID: <?=$SiteID;?>, UID: <?=$UserID;?>, SID: '<?=$Session;?>', NODE: NodeID }, success: function( response, opts ){ // If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText); var tPanel = Ext.getCmp('prop_content'); tPanel.remove(0); tPanel.add( data ); tPanel.doLayout(); }, failure: failureAJAXFunction });};
function LoadNodesList(){ Ext.Ajax.request({ url: '/lib/controller/getLocationNodes.php', params: { SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, SID: '<?=$Session;?>' }, success: function( response, opts ){ // If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText); var tPanel = Ext.getCmp('prop_content'); tPanel.remove(0); tPanel.add( data ); tPanel.doLayout(); }, failure: failureAJAXFunction });};
function loadLocationEditor( el_id , node_type, node_id, lat, lon ){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; if( node_type == undefined ) node_type = 0; if( lat == undefined ){ lat = SiteLat; lon = SiteLon; }; map_ed = L.map( el_id,{ attributionControl: true, //preferCanvas: true,
zoomControl: true, center: [SiteLat, SiteLon], /*zoomControl: false, zoom: 17, minZoom: 17, maxZoom: 17,*/ keyboard: false }).setView([SiteLat, SiteLon], 17); if( node_type ){ L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
} else { 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();
}; var mapLayers = []; mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', maxNativeZoom: 18, maxZoom: 24, }) // https://leaflet-extras.github.io/leaflet-providers/preview/
mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012', maxZoom: 19 });
mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', maxZoom: 19 });
mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © <a href="https://www.esri.com" target="_blank">Esri</a> — 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', maxZoom: 24 });
mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
attribution: 'Map data © <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors', maxZoom: 19 });
mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", { attribution: 'Kartendaten: © <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: © <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>) ', maxZoom: 19 }); var baseMaps = { "MyMap": mapLayers["MyMap"], "OpenStreetMap": mapLayers["OpenStreetMap"], "OpenTopoMap": mapLayers["OpenTopoMap"], "EsriSat": mapLayers["EsriSat"], "EsriStreet": mapLayers["EsriStreet"], "EsriTopo": mapLayers["EsriTopo"], //"Bing": mapLayers["Bing"],
//"OSM-Cycle": mapLayers["Cycle"],
//"Landscape": mapLayers["Landscape"],
//"Outdoor": mapLayers["Outdoor"],
}; L.control.layers( baseMaps ).addTo( map_ed ); mapLayers["MyMap"].addTo( map_ed ); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo( map_ed );
if( node_type ){ switch( node_type ){ case 1:{ 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 ); break; }; case 2:{ 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 ); break; }; case 3:{ 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 ); break; }; case 4:{ 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 ); break; }; case 5:{ 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 ); break; }; case 6:{ 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 ); break; }; case 10: case 12:{ 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 ); break; }; case 11: case 13:{ 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 ); break; }; }; } else loadLocationNodes();};
function updateSiteAnchor(){ SiteLat = Ext.getCmp('siteLat').getValue(); SiteLon = Ext.getCmp('siteLon').getValue(); SiteAlt = Ext.getCmp('siteAlt').getValue(); Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 1, SID: '<?=$Session;?>', LAT: SiteLat, LON: SiteLon, ALT: SiteAlt }, failure: failureAJAXFunction });};
function updateLocationOrientation(){ var tLat = Ext.getCmp('slat').getValue(); var tLon = Ext.getCmp('slon').getValue(); var tAlt = Ext.getCmp('salt').getValue(); var tRoll = Ext.getCmp('sroll').getValue(); var tPitch = Ext.getCmp('spitch').getValue(); var tYaw = Ext.getCmp('syaw').getValue(); Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, UID: <?=$UserID;?>, TYPE: 2, SID: '<?=$Session;?>', LAT: tLat, LON: tLon, ALT: tAlt, YAW: tYaw, ROLL: tRoll, PITCH: tPitch }, failure: failureAJAXFunction });};
var iconSaver = null;var markerSaver = null;
function updateLocation( e ){ locationSelectedNode = e.target.options.mycustomid; Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 0, SID: '<?=$Session;?>', LAT: e.target._latlng.lat, LON: e.target._latlng.lng }, success: function( response, opts ){ loadNodeLocationProps( locationSelectedNode ); }, failure: failureAJAXFunction });};
function markerDblClick( e ){ if( iconSaver == null ){ iconSaver = e.target.options.icon; markerSaver = e.target; e.target.setIcon( SNAPE_Icon ); for( i=0; i< markers.length; i++){ if( markers[i].options.mycustomid != e.target.options.mycustomid ){ markers[i].setOpacity( 0.1 ); } else { markers[i].setOpacity( 1.0 ); } }; } else { if( e.target.options.mycustomid == markerSaver.options.mycustomid ){ e.target.setIcon( iconSaver ); iconSaver = null; markerSaver = null; for( i=0; i< markers.length; i++){ markers[i].setOpacity( 1.0 ); }; } else { markerSaver.setIcon( iconSaver ); iconSaver = e.target.options.icon; markerSaver = e.target; e.target.setIcon( SNAPE_Icon ); for( i=0; i< markers.length; i++){ if( markers[i].options.mycustomid != e.target.options.mycustomid ){ markers[i].setOpacity( 0.1 ); } else { markers[i].setOpacity( 1.0 ); } }; }; };};
function setNodeLocationToAnchor(){ Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 0, SID: '<?=$Session;?>', LAT: SiteLat, LON: SiteLon, ALT: SiteAlt }, success: function( response, opts ){ loadLocationEditor(); }, failure: failureAJAXFunction });};
function setNodeLocationByDelta(){ var dx = Ext.getCmp('dx').getValue(); var dy = Ext.getCmp('dy').getValue(); var dz = Ext.getCmp('dz').getValue(); Ext.Ajax.request({ url: '/lib/controller/updateLocation.php', params: { NODE: locationSelectedNode, SITE: <?=$SiteID;?>, UID: <?=$UserID;?>, TYPE: 3, SID: '<?=$Session;?>', LAT: dx, LON: dy, ALT: dz }, success: function( response, opts ){ loadLocationEditor(); }, failure: failureAJAXFunction });};
|