/**
* map.js
*/
Ext.Loader.setConfig({
enabled: true
});
Ext.Loader.setPath('Ext.ux', '../../res/extjs/examples/ux');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ux.RowExpander',
'Ext.selection.CheckboxModel'
]);
var sm = Ext.create('Ext.selection.CheckboxModel');
var myMask;
var baseUrl = "";
var theme = "";
var mapStyle = "";
var map;
var mapzoom = 11;
var company_cur = 0;
var StatusStore = null,
AlarmStore = null;
var firstDraw = true;
var storeTime = 60000;
var centerLng = 121.475644;
var currentLng = 121.475644;
var centerLat = 31.1857;
var currentLat = 31.1857;
var rotation = 0;
var alarm_show_window = null;
var show_alarm_list;
var show_list_cur = 0
var V_LOGINNAME = '',
V_PASSWORD = '';
var listSync = true;
var synctime = 0;
var company_code = '';
var start = 0;
var end = 360;
var targetZoom = 20;
var maxHeight = 10000;
var maxWidth = 10000;
var SearchList = null;
var markers = [];
var current_company_code = "";
var LabelShow = false;
var MapShow = false;
var last_move;
var wsUri = "wss://iot.usky.cn:55120";
var websocket = null;
var win1_config = {
title: '
',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 100,
left: 50,
zIndex: 200,
bodyText: ''
}
var win2_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 260,
left: 50,
zIndex: 260,
bodyText: ''
}
var win3_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 420,
left: 50,
zIndex: 260,
bodyText: ''
}
var win4_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 580,
left: 50,
zIndex: 260,
bodyText: ''
}
var dev1_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 219,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var dev2_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 379,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var dev3_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 539,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var dev4_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 699,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var alarm_alert_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid #31e9ff',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
bottom: -100,
right: 95,
zIndex: 990,
bodyText: ''
}
var winypxy1_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 60,
left: 50,
zIndex: 200,
bodyText: ''
}
var devypxy1_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 179,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var winypxy2_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 220,
left: 50,
zIndex: 260,
bodyText: ''
}
var winypxy3_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 380,
left: 50,
zIndex: 260,
bodyText: ''
}
var winypxy4_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 540,
left: 50,
zIndex: 260,
bodyText: ''
}
var winypxy5_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 120,
top: 700,
left: 50,
zIndex: 260,
bodyText: ''
}
var devypxy2_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 339,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var devypxy3_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 499,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var devypxy4_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 659,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var devypxy5_config = {
title: '',
titleColor: '#ffffff',
titleIconColor: '#ffffff',
titleBackgroundColor: 'rgba(0,0,0,0.1)',
backgroundColor: 'rgba(23,21,57,0.2)',
backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
border: '1px solid rgba(0,123,255,0.3)',
borderRadius: '10px',
position: 'absolute',
width: 320,
height: 100,
top: 819,
left: 50,
zIndex: 200,
floding: 'true',
bodyText: ''
}
var close_alert = function() {
removeDIV("rt_alarm_alert");
}
var initWebSocket = function() {
try {
if (typeof MozWebSocket == 'function')
WebSocket = MozWebSocket;
if (websocket && websocket.readyState == 1)
websocket.close();
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) {
var json = {};
json.agentid = $("#V_LOGINNAME").val();
console.log("Connected.");
(function() {})()
websocket.send(JSON.stringify(json));
};
websocket.onclose = function(evt) {
console.log("DisConnected.");
(function() {})()
initWebSocket();
};
websocket.onmessage = function(evt) {
console.log("Received:", evt.data);
var jData = eval('(' + evt.data + ')');
if (jData.dwtype != undefined) {
if (document.getElementById('rt_alarm_alert') != undefined)
removeDIV('rt_alarm_alert');
var alarm_alert = new UNote();
alarm_alert.create("rt_alarm_alert", "container", alarm_alert_config);
var Icon = document.createElement('img');
Icon.width = '32';
Icon.height = '32';
Icon.src = "../../res/img/icons/alarm_tab_04.gif"
if (jData.detype == 1) {
Icon.src = "../../res/img/icons/alarm_tab_01.gif"
} else if (jData.dwtype == 2) {
Icon.src = "../../res/img/icons/alarm_tab_03.gif"
} else if (jData.dwtype == 6) {
Icon.src = "../../res/img/icons/alarm_tab_04.gif"
} else if (jData.dwtype == 7) {
Icon.src = "../../res/img/icons/alarm_tab_02.gif"
} else if (jData.dwtype == 16) {
Icon.src = "../../res/img/icons/alarm_tab_05.gif"
}
document.getElementById("rt_alarm_alert_icon").innerHTML = "";
document.getElementById("rt_alarm_alert_icon").appendChild(Icon);
document.getElementById("rt_alarm_alert_title").innerHTML = jData.evtname;
document.getElementById("alarm_time").innerHTML = jData.time;
document.getElementById("alarm_company").innerHTML = jData.company;
document.getElementById("alarm_device").innerHTML = jData.devicename;
alarm_alert.show();
$("#rt_alarm_alert").animate({
bottom: '0px'
});
}
};
websocket.onerror = function(evt) {
console.log("Error:", evt.data);
(function() {})()
};
} catch (exception) {
console.log("Exception:", exception);
(function() {})()
}
}
var toDecimal = function(x) {
var f = parseFloat(x);
if (isNaN(f)) {
return;
}
f = Math.round(x * 100) / 100;
return f;
}
var bigger_mouseover = function() {
$("#map_btn_bigger").removeClass('map_btn_bigger_off');
$("#map_btn_bigger").addClass('map_btn_bigger_on');
}
var bigger_mouseout = function() {
$("#map_btn_bigger").removeClass('map_btn_bigger_on');
$("#map_btn_bigger").addClass('map_btn_bigger_off');
}
var bigger_click = function() {
map.zoomIn();
}
var smaller_mouseover = function() {
$("#map_btn_smaller").removeClass('map_btn_smaller_off');
$("#map_btn_smaller").addClass('map_btn_smaller_on');
}
var smaller_mouseout = function() {
$("#map_btn_smaller").removeClass('map_btn_smaller_on');
$("#map_btn_smaller").addClass('map_btn_smaller_off');
}
var smaller_click = function() {
map.zoomOut();
}
var shower_mouseover = function() {
if (!LabelShow) {
$("#map_btn_showlaebl").removeClass('map_btn_showlaebl_off');
$("#map_btn_showlaebl").addClass('map_btn_showlaebl_on');
}
}
var shower_mouseout = function() {
if (!LabelShow) {
$("#map_btn_showlaebl").removeClass('map_btn_showlaebl_on');
$("#map_btn_showlaebl").addClass('map_btn_showlaebl_off');
}
}
var shower_click = function() {
LabelShow = !LabelShow;
if (LabelShow) {
$("#map_btn_showlaebl").removeClass('map_btn_showlaebl_on');
$("#map_btn_showlaebl").addClass('map_btn_hidelabel');
$(".info").removeClass('hiden');
$(".info").addClass('shown');
} else {
$("#map_btn_showlaebl").removeClass('map_btn_hidelabel');
$("#map_btn_showlaebl").addClass('map_btn_showlaebl_on');
$(".info").removeClass('shown');
$(".info").addClass('hiden');
}
}
var left_mouseover = function() {
$("#map_btn_left").removeClass('map_btn_left_off');
$("#map_btn_left").addClass('map_btn_left_on');
}
var left_mouseout = function() {
$("#map_btn_left").removeClass('map_btn_left_on');
$("#map_btn_left").addClass('map_btn_left_off');
}
var left_click = function() {
rotation = map.getRotation();
rotation -= 5;
if (rotation < 0)
rotation = 360 + rotation;
map.setRotation(rotation);
draw_all();
}
var right_mouseover = function() {
$("#map_btn_right").removeClass('map_btn_right_off');
$("#map_btn_right").addClass('map_btn_right_on');
}
var right_mouseout = function() {
$("#map_btn_right").removeClass('map_btn_right_on');
$("#map_btn_right").addClass('map_btn_right_off');
}
var right_click = function() {
rotation = map.getRotation();
rotation += 5;
if (rotation > 360)
rotation = rotation - 360;
map.setRotation(rotation);
draw_all();
}
var higher_mouseover = function() {
$("#map_btn_high").removeClass('map_btn_high_off');
$("#map_btn_high").addClass('map_btn_high_on');
}
var higher_mouseout = function() {
$("#map_btn_high").removeClass('map_btn_high_on');
$("#map_btn_high").addClass('map_btn_high_off');
}
var higher_click = function() {
var pitch = map.getPitch();
pitch -= 5;
if (pitch < 0)
pitch = 0;
map.setPitch(pitch);
}
var lower_mouseover = function() {
$("#map_btn_low").removeClass('map_btn_low_off');
$("#map_btn_low").addClass('map_btn_low_on');
}
var lower_mouseout = function() {
$("#map_btn_low").removeClass('map_btn_low_on');
$("#map_btn_low").addClass('map_btn_low_off');
}
var lower_click = function() {
var pitch = map.getPitch();
pitch += 5;
if (pitch > 83)
pitch = 83;
map.setPitch(pitch);
}
var clear_search = function() {
SearchList = null
show_list_cur = 0;
$("#fp_backbtn").css("display", "none");
firstDraw = true;
if ($("#search_company").val().length > 0) {
$("#search_company").val('');
$("#company_code").val('');
$("#saerch_company_list").html('');
}
if ((!LabelShow) && (StatusStore.length > 0)) {
for (var i = 0; i < StatusStore.length; i++) {
$("#label_" + StatusStore[i].company_code).css('display', 'none');
}
}
}
var update_companyList = function() {
$("#saerch_company_list").html('');
SearchList = null
show_list_cur = 0;
if ($("#search_company").val().length > 0) {
var query = new Object();
query.V_LOGINNAME = V_LOGINNAME;
query.V_PASSWORD = V_PASSWORD;
query.V_COMPANY_NAME = $("#search_company").val();
$.ajax({
type: 'POST',
url: baseUrl + "/iot/company/getList",
data: {
queryJson: Ext.JSON.encode(query),
sort: "[{property:'V_COMPANY_NAME',direction:'ASC'}]"
},
success: function(result) {
var json = eval('(' + result + ')');
if (json.action == 'getCompanyList') {
var list = json.RESULT;
if (list.length > 0) {
SearchList = list;
var saerch_company_list = document.getElementById('saerch_company_list');
var table = document.createElement('table');
table.border = '0';
table.style.width = '300px';
table.style.border = '0px solid #000';
saerch_company_list.appendChild(table);
for (var i = 0; i < list.length; i++) {
var tr = document.createElement('tr');
tr.style.border = '0px solid #000';
table.appendChild(tr);
var td = document.createElement('td');
td.id = 'company_code_list_' + list[i].V_COMPANY_CODE;
td.company_code = list[i].V_COMPANY_CODE;
td.style.border = '1px solid rgba(255,255,255,0.0)';
td.style.background = 'rgba(255,255,255,0.3)';
td.style.fontSize = '14px';
td.style.cursor = "pointer";
td.innerHTML = list[i].V_COMPANY_NAME;
tr.appendChild(td);
$("#company_code_list_" + list[i].V_COMPANY_CODE).mouseover(function() {
$(this).css({ "border": "1px solid rgba(64,85,98,0.7)", "background": "rgba(64,85,98,0.7)", "color": "#ffff00", "cursor": "pointer", "font-size": "14px" });
$("#label_" + this.company_code).css('display', 'block');
show_list_cur = i + 1;