-
-
Save djcas9/e15275dd6b467b44219f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var renderIpData = function(events) { | |
if (events) { | |
for (var i = 0; i < events.length; i += 1) { | |
var current = events[i] | |
var slat = current.src_geoip.latitude; | |
var slong = current.src_geoip.longitude; | |
var dlat = current.dst_geoip.latitude; | |
var dlong = current.dst_geoip.longitude; | |
var pointA = new L.LatLng(slat, slong); | |
var pointB = new L.LatLng(dlat, dlong); | |
var pointList = [pointA, pointB]; | |
var polyline = L.polyline(pointList, { | |
color: 'red', | |
weight: 2, | |
opacity: 0.5, | |
smoothFactor: 1 | |
}); | |
polyline.bindPopup(current.ip_src + " <=> " + current.ip_dst); | |
map.addLayer(polyline); | |
polyline.on('mouseover', function(e) { | |
console.log(this) | |
this.setStyle({ | |
color: "green", | |
opacity: 1 | |
}); | |
this.bringToFront(); | |
}); | |
polyline.on('mouseout', function(e) { | |
this.setStyle({ | |
color: 'red', | |
weight: 2, | |
opacity: 0.5, | |
smoothFactor: 1 | |
}); | |
this.bringToBack(); | |
}); | |
if (plotList.indexOf(current.ip_src) < 1) { | |
var m = L.marker([slat, slong], { | |
title: current.ip_src | |
}).addTo(map) | |
.bindPopup('A pretty CSS3 popup. <br> Easily customizable.'); | |
m.on('click', function(e) { | |
console.log(this); | |
polyline.setStyle({ | |
color: "green" | |
}); | |
}); | |
}; | |
if (plotList.indexOf(current.ip_dst) < 1) { | |
var m = L.marker([dlat, dlong], { | |
title: current.ip_dst | |
}).addTo(map) | |
.bindPopup('A pretty CSS3 popup. <br> Easily customizable.'); | |
m.on('click', function(e) { | |
console.log(this); | |
polyline.setStyle({ | |
color: "green" | |
}); | |
}); | |
}; | |
plotList.push(current.ip_src); | |
plotList.push(current.ip_dst); | |
} // loop | |
}; | |
}; // render ip data | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment