86 lines
3.1 KiB
JavaScript
86 lines
3.1 KiB
JavaScript
|
// calculate marker radius from magnitude, both formulas have equal radii at mag=1.2
|
||
|
function mag2radius(mag) {
|
||
|
return 400*mag; // radius proportional to magagnitude
|
||
|
// return 8.104*Math.pow(30,mag) // radius proportional to energy
|
||
|
};
|
||
|
|
||
|
// set height of eventlist div
|
||
|
function sleep(milliseconds) {
|
||
|
var start = new Date().getTime();
|
||
|
for (var i = 0; i < 1e7; i++) {
|
||
|
if ((new Date().getTime() - start) > milliseconds){
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function setInfoHeight() {
|
||
|
var height = $('div.map').height() - 36;
|
||
|
$('div.info').height(height);
|
||
|
//$('.tab').height(height-80);
|
||
|
//$('#eventtable').height(height-100);
|
||
|
};
|
||
|
|
||
|
/* get region and regionID of a location */
|
||
|
function getLocation(lat, lng) {
|
||
|
var region = false;
|
||
|
var regionID;
|
||
|
var regions = [
|
||
|
['Monschau', 'Schleiden', 'Bad Münstereifel', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Hessen', 'Hessen', 'Hessen', 'Hessen'],
|
||
|
['Aachen', 'Zülpich', 'Euskirchen', 'Bonn', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Hessen', 'Hessen', 'Hessen', 'Hessen'],
|
||
|
['Geilenkirchen', 'Düren', 'Köln', 'Köln-Mülheim', 'Waldbröl', 'Freudenberg', 'Siegen', 'Hessen', 'Hessen', 'Hessen'],
|
||
|
['Heinsberg', 'Mönchengladbach', 'Neuss', 'Solingen', 'Gummersbach', 'Olpe', 'Schmallenberg', 'Bad Berleburg', 'Hessen', 'Hessen'],
|
||
|
['Nettetal', 'Krefeld', 'Düsseldorf', 'Wuppertal', 'Hagen', 'Iserlohn', 'Arnsberg', 'Brilon', 'Hessen', 'Hessen'],
|
||
|
['Geldern', 'Moers', 'Duisburg', 'Essen', 'Dortmund', 'Unna', 'Soest', 'Büren', 'Marsberg', 'Warburg'],
|
||
|
['Kleve', 'Wesel', 'Dorsten', 'Recklinghausen', 'Lünen', 'Hamm/Westfalen', 'Beckum', 'Lippstadt', 'Paderborn', 'Bad Driburg'],
|
||
|
['Emmerich am Rhein', 'Bocholt', 'Borken', 'Coesfeld', 'Münster', 'Warendorf', 'Rheda-Wiedenbrück', 'Gütersloh', 'Detmold', 'Bad Pyrmont'],
|
||
|
['The Netherlands', 'The Netherlands', 'Vreden', 'Ahaus', 'Steinfurt', 'Lengerich', 'Bad Ilburg', 'Bielefeld', 'Herford', 'Niedersachsen'],
|
||
|
['The Netherlands', 'The Netherlands', 'The Netherlands', 'Niedersachsen', 'Rheine', 'Ibbenbüren', 'Niedersachsen', 'Lübbecke', 'Minden', 'Niedersachsen']
|
||
|
];
|
||
|
if ( lat >= 50.4 && lat < 52.4 && lng >= 6.0 && lng < 9.333333 ) {
|
||
|
var latIndex = Math.floor((lat-50.4)*5); // 5 tiles per degree
|
||
|
var lngIndex = Math.floor((lng-6.0)*3); // 3 tiles per degree
|
||
|
region = regions[latIndex][lngIndex];
|
||
|
};
|
||
|
if ( region != 'The Netherlands' ) {
|
||
|
regionID = 5500-latIndex*200+lngIndex*2+2;
|
||
|
};
|
||
|
if ( lat >= 50.9 && lat < 51.1 && lng >= 5.666666 && lng < 6.0 ) {
|
||
|
region = 'Selfkant';
|
||
|
regionID = 5000;
|
||
|
};
|
||
|
return [ region, regionID ];
|
||
|
};
|
||
|
|
||
|
// window resize
|
||
|
$( window ).resize(function() {
|
||
|
setInfoHeight();
|
||
|
});
|
||
|
|
||
|
// create global vars
|
||
|
var map
|
||
|
var eventTable = {};
|
||
|
var eventDetails = {};
|
||
|
var stationTable = {};
|
||
|
var eventMarkerOpacity = 0.3;
|
||
|
var stationMarkerOpacity = 0.5;
|
||
|
var zoomFocus = 12;
|
||
|
var zoomDefault = 9;
|
||
|
var mapCentreDefault = [51.85, 7.0];
|
||
|
var minMag = 1.2;
|
||
|
|
||
|
// run when ready
|
||
|
$(document).ready(function() {
|
||
|
// AJAX setup
|
||
|
$.ajaxSetup({timeout: 15000}); // 15 seconds
|
||
|
// adjust height of infocontainer
|
||
|
setInfoHeight();
|
||
|
// create tabs
|
||
|
var tabOptions = {
|
||
|
active: 0,
|
||
|
disabled: [2, 3],
|
||
|
};
|
||
|
$('#tabs').tabs(tabOptions);
|
||
|
// $('.ui-tabs-nav').sortable();
|
||
|
});
|
||
|
|