mirror of https://github.com/MISP/misp-dashboard
Removed code duplication
parent
5c5b27fc2d
commit
4d0136bdb8
|
@ -7,7 +7,7 @@ const OSMURL='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
const OSMATTRIB='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
|
const OSMATTRIB='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
|
||||||
|
|
||||||
var myOpenStreetMap = L.map('feedDivMap1').setView([0, 0], 1);
|
var myOpenStreetMap = L.map('feedDivMap1').setView([0, 0], 1);
|
||||||
var osm = new L.TileLayer(OSMURL, {minZoom: 0, maxZoom: 17, attribution: OSMATTRIB}).addTo(myOpenStreetMap);
|
var osm = new L.TileLayer(OSMURL, {minZoom: 0, maxZoom: 17}).addTo(myOpenStreetMap);
|
||||||
|
|
||||||
class MapEvent {
|
class MapEvent {
|
||||||
constructor(json, marker) {
|
constructor(json, marker) {
|
||||||
|
@ -60,7 +60,7 @@ class MapEventManager {
|
||||||
this.ping();
|
this.ping();
|
||||||
this._first_map = false;
|
this._first_map = false;
|
||||||
} else {
|
} else {
|
||||||
this.setMap(mapevent);
|
this.rotateMap(mapevent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,11 @@ class MapEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the roration of the map in the openStreetMap pannel
|
// Perform the roration of the map in the openStreetMap pannel
|
||||||
rotateMap() {
|
rotateMap(mapEvent) {
|
||||||
|
clearTimeout(this._timeoutRotate); //cancel current map rotation
|
||||||
|
if (mapEvent == undefined) {
|
||||||
var mapEvent = this.getNextEventToShow();
|
var mapEvent = this.getNextEventToShow();
|
||||||
|
}
|
||||||
this._latToPing = mapEvent.coord.lat;
|
this._latToPing = mapEvent.coord.lat;
|
||||||
this._lonToPing = mapEvent.coord.lon;
|
this._lonToPing = mapEvent.coord.lon;
|
||||||
var marker = mapEvent.marker;
|
var marker = mapEvent.marker;
|
||||||
|
@ -87,18 +90,6 @@ class MapEventManager {
|
||||||
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
this._timeoutRotate = setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMap(mapEvent) {
|
|
||||||
clearTimeout(this._timeoutRotate); //cancel current map rotation
|
|
||||||
this._latToPing = mapEvent.coord.lat;
|
|
||||||
this._lonToPing = mapEvent.coord.lon;
|
|
||||||
var marker = mapEvent.marker;
|
|
||||||
myOpenStreetMap.flyTo([mapEvent.coord.lat, mapEvent.coord.lon], 15);
|
|
||||||
mapEvent.marker.bindPopup(mapEvent.textMarker).openPopup();
|
|
||||||
|
|
||||||
$("#textMap1").fadeOut(400, function(){ $(this).text(mapEvent.text); }).fadeIn(400);
|
|
||||||
setTimeout(function(){ mapEventManager.rotateMap(); }, ROTATIONWAITTIME);
|
|
||||||
}
|
|
||||||
|
|
||||||
ping() {
|
ping() {
|
||||||
var pnts = openStreetMapObj.latLngToPoint(this._latToPing, this._lonToPing);
|
var pnts = openStreetMapObj.latLngToPoint(this._latToPing, this._lonToPing);
|
||||||
if (pnts != false) { //sometimes latLngToPoint return false
|
if (pnts != false) { //sometimes latLngToPoint return false
|
||||||
|
|
Loading…
Reference in New Issue