|
|
@ -40,33 +40,32 @@ function loadGeoFencing() {
|
|
|
|
|
|
|
|
|
|
|
|
function openTools(id) {
|
|
|
|
function openTools(id) {
|
|
|
|
lastId = id;
|
|
|
|
lastId = id;
|
|
|
|
if(drawControl){
|
|
|
|
if (drawControl) {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
map.removeControl(drawControl);
|
|
|
|
map.removeControl(drawControl);
|
|
|
|
}catch(e){
|
|
|
|
} catch(e) {
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log("removed drawControl");
|
|
|
|
console.log("removed drawControl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(removeAllControl){
|
|
|
|
if (removeAllControl) {
|
|
|
|
try{
|
|
|
|
try {
|
|
|
|
map.removeControl(removeAllControl);
|
|
|
|
map.removeControl(removeAllControl);
|
|
|
|
}catch(e){
|
|
|
|
} catch(e) {
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log("removed removeAllControl");
|
|
|
|
console.log("removed removeAllControl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(drawnItems){
|
|
|
|
if (drawnItems) {
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
map.removeLayer(drawnItems);
|
|
|
|
map.removeLayer(drawnItems);
|
|
|
|
console.log("removing layer");
|
|
|
|
console.log("removing layer");
|
|
|
|
}catch(e){
|
|
|
|
} catch(e) {
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
console.log("error: " + e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log("removed drawnItems");
|
|
|
|
console.log("removed drawnItems");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeAll();
|
|
|
|
closeAll();
|
|
|
|
noty({text: "Please draw the required area on the map", type: "information"});
|
|
|
|
noty({text: "Please draw the required area on the map", type: "information"});
|
|
|
|
|
|
|
|
|
|
|
@ -107,12 +106,11 @@ function openTools(id) {
|
|
|
|
removeAllControl = new L.Control.RemoveAll();
|
|
|
|
removeAllControl = new L.Control.RemoveAll();
|
|
|
|
map.addControl(removeAllControl);
|
|
|
|
map.addControl(removeAllControl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialise the FeatureGroup to store editable layers
|
|
|
|
// Initialise the FeatureGroup to store editable layers
|
|
|
|
drawnItems = new L.FeatureGroup();
|
|
|
|
drawnItems = new L.FeatureGroup();
|
|
|
|
map.addLayer(drawnItems);
|
|
|
|
map.addLayer(drawnItems);
|
|
|
|
|
|
|
|
|
|
|
|
if(id=="WithIn"){
|
|
|
|
if (id=="WithIn") {
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
draw: {
|
|
|
|
draw: {
|
|
|
@ -139,7 +137,7 @@ function openTools(id) {
|
|
|
|
featureGroup: drawnItems
|
|
|
|
featureGroup: drawnItems
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Exit"){
|
|
|
|
} else if (id=="Exit") {
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
draw: {
|
|
|
|
draw: {
|
|
|
@ -168,7 +166,6 @@ function openTools(id) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Stationery"){
|
|
|
|
} else if(id=="Stationery"){
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
|
|
|
|
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
draw: {
|
|
|
|
draw: {
|
|
|
|
polygon: {
|
|
|
|
polygon: {
|
|
|
@ -198,7 +195,7 @@ function openTools(id) {
|
|
|
|
featureGroup: drawnItems
|
|
|
|
featureGroup: drawnItems
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Traffic"){
|
|
|
|
} else if (id=="Traffic") {
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
// Initialise the draw control and pass it the FeatureGroup of editable layers
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
draw: {
|
|
|
|
draw: {
|
|
|
@ -233,7 +230,7 @@ function openTools(id) {
|
|
|
|
featureGroup: drawnItems
|
|
|
|
featureGroup: drawnItems
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id =="Prediction"){
|
|
|
|
} else if (id =="Prediction") {
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
drawControl = new L.Control.Draw({
|
|
|
|
draw: {
|
|
|
|
draw: {
|
|
|
|
polygon: false,
|
|
|
|
polygon: false,
|
|
|
@ -252,28 +249,24 @@ function openTools(id) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log("prediction tool opened");
|
|
|
|
console.log("prediction tool opened");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
map.addControl(drawControl);
|
|
|
|
map.addControl(drawControl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createPopup(layer,id) {
|
|
|
|
function createPopup(layer,id) {
|
|
|
|
if(id=="WithIn"){
|
|
|
|
if (id=="WithIn") {
|
|
|
|
var popupTemplate = $('#setWithinAlert');
|
|
|
|
var popupTemplate = $('#setWithinAlert');
|
|
|
|
popupTemplate.find('#addWithinAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
popupTemplate.find('#addWithinAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
} else if(id=="Exit"){
|
|
|
|
} else if (id=="Exit") {
|
|
|
|
var popupTemplate = $('#setExitAlert');
|
|
|
|
var popupTemplate = $('#setExitAlert');
|
|
|
|
popupTemplate.find('#addExitAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
popupTemplate.find('#addExitAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
} else if(id=="Stationery"){
|
|
|
|
} else if (id=="Stationery") {
|
|
|
|
var popupTemplate = $('#setStationeryAlert');
|
|
|
|
var popupTemplate = $('#setStationeryAlert');
|
|
|
|
popupTemplate.find('#addStationeryAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
popupTemplate.find('#addStationeryAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
} else if(id=="Traffic"){
|
|
|
|
} else if (id=="Traffic") {
|
|
|
|
var popupTemplate = $('#setTrafficAlert');
|
|
|
|
var popupTemplate = $('#setTrafficAlert');
|
|
|
|
popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
popupTemplate.find('#addTrafficAlert').attr('leaflet_id', layer._leaflet_id);
|
|
|
|
//console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id);
|
|
|
|
//console.log(">>got here " + id + " " + popupTemplate.find('#addTrafficAlert') + " " + layer._leaflet_id);
|
|
|
|
} else if(id=="Prediction"){
|
|
|
|
} else if (id=="Prediction") {
|
|
|
|
getPrediction(layer._leaflet_id);
|
|
|
|
getPrediction(layer._leaflet_id);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -364,7 +357,7 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
var areaName = $(geoFenceElement).attr('data-areaName');
|
|
|
|
var areaName = $(geoFenceElement).attr('data-areaName');
|
|
|
|
var geometryShape;
|
|
|
|
var geometryShape;
|
|
|
|
|
|
|
|
|
|
|
|
if(geoJson.type=="Point"){
|
|
|
|
if (geoJson.type=="Point") {
|
|
|
|
|
|
|
|
|
|
|
|
var circleOptions = {
|
|
|
|
var circleOptions = {
|
|
|
|
color: '#ff0043'
|
|
|
|
color: '#ff0043'
|
|
|
@ -373,7 +366,7 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
|
|
|
|
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
|
|
|
|
map.addLayer(geometryShape);
|
|
|
|
map.addLayer(geometryShape);
|
|
|
|
// map.addLayer(marker);
|
|
|
|
// map.addLayer(marker);
|
|
|
|
} else if(geoJson.type=="Polygon"){
|
|
|
|
} else if (geoJson.type=="Polygon") {
|
|
|
|
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
|
|
|
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
|
|
|
var leafletLatLngs = [];
|
|
|
|
var leafletLatLngs = [];
|
|
|
|
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
|
|
|
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
|
|
@ -385,7 +378,7 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
|
|
|
|
|
|
|
|
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
|
|
|
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
|
|
|
|
|
|
|
|
|
|
|
if(id=="Stationery"){
|
|
|
|
if (id=="Stationery") {
|
|
|
|
|
|
|
|
|
|
|
|
var stationeryTime=$(geoFenceElement).attr('data-stationeryTime');
|
|
|
|
var stationeryTime=$(geoFenceElement).attr('data-stationeryTime');
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
|
|
@ -401,7 +394,7 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="WithIn"){
|
|
|
|
} else if (id=="WithIn") {
|
|
|
|
|
|
|
|
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
|
|
@ -414,7 +407,7 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Exit"){
|
|
|
|
} else if (id=="Exit") {
|
|
|
|
|
|
|
|
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
|
|
@ -427,7 +420,6 @@ function viewFence(geoFenceElement,id) {
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Traffic"){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closeAll();
|
|
|
|
closeAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -440,7 +432,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
geoJson = JSON.parse(geoJson.replace(/'/g, '"'));
|
|
|
|
geoJson = JSON.parse(geoJson.replace(/'/g, '"'));
|
|
|
|
var geometryShape;
|
|
|
|
var geometryShape;
|
|
|
|
|
|
|
|
|
|
|
|
if(geoJson.type=="Point"){
|
|
|
|
if (geoJson.type=="Point") {
|
|
|
|
|
|
|
|
|
|
|
|
var circleOptions = {
|
|
|
|
var circleOptions = {
|
|
|
|
color: '#ff0043'
|
|
|
|
color: '#ff0043'
|
|
|
@ -449,7 +441,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
|
|
|
|
// var marker=new L.marker([geoJson.coordinates[1],geoJson.coordinates[0]]);
|
|
|
|
map.addLayer(geometryShape);
|
|
|
|
map.addLayer(geometryShape);
|
|
|
|
// map.addLayer(marker);
|
|
|
|
// map.addLayer(marker);
|
|
|
|
} else if(geoJson.type=="Polygon"){
|
|
|
|
} else if (geoJson.type=="Polygon") {
|
|
|
|
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
|
|
|
geoJson.coordinates[0].pop(); // popout the last coordinate set(lat,lng pair) due to circular chain
|
|
|
|
var leafletLatLngs = [];
|
|
|
|
var leafletLatLngs = [];
|
|
|
|
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
|
|
|
$.each(geoJson.coordinates[0], function (idx, pItem) {
|
|
|
@ -461,7 +453,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
|
|
|
|
|
|
|
|
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
|
|
|
var geoPublicUri = $("#geo-charts").data("geo-public-uri");
|
|
|
|
|
|
|
|
|
|
|
|
if(id=="Stationery"){
|
|
|
|
if (id=="Stationery") {
|
|
|
|
|
|
|
|
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewStationeryAlert", function () {
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewStationeryAlert');
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewStationeryAlert');
|
|
|
@ -473,7 +465,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="WithIn"){
|
|
|
|
} else if (id=="WithIn") {
|
|
|
|
|
|
|
|
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewWithinAlert", function () {
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewWithinAlert');
|
|
|
@ -486,7 +478,7 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Exit"){
|
|
|
|
} else if (id=="Exit") {
|
|
|
|
|
|
|
|
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
|
|
|
$('#templateLoader').load(geoPublicUri + "/assets/html_templates/view_fence_popup.html #viewExitAlert", function () {
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
|
|
|
var popupTemplate = $('#templateLoader').find('#viewExitAlert');
|
|
|
@ -499,7 +491,6 @@ function viewFenceByData(geoJson, queryName, areaName, stationeryTime, id) {
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
// transparent the layer .leaflet-popup-content-wrapper
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
$(geometryShape._popup._container.childNodes[0]).css("background", "rgba(255,255,255,0.8)");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if(id=="Traffic"){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closeAll();
|
|
|
|
closeAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|