improved search for coordinates, including intel links
This commit is contained in:
@ -219,6 +219,8 @@ window.search.setup = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// search for portals
|
||||||
addHook('search', function(query) {
|
addHook('search', function(query) {
|
||||||
var term = query.term.toLowerCase();
|
var term = query.term.toLowerCase();
|
||||||
var teams = ['NEU','RES','ENL'];
|
var teams = ['NEU','RES','ENL'];
|
||||||
@ -251,21 +253,40 @@ addHook('search', function(query) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// search for locations
|
||||||
// TODO: recognize 50°31'03.8"N 7°59'05.3"E and similar formats
|
// TODO: recognize 50°31'03.8"N 7°59'05.3"E and similar formats
|
||||||
// TODO: if a portal with these exact coordinates is found, select it
|
|
||||||
addHook('search', function(query) {
|
addHook('search', function(query) {
|
||||||
if(query.term.split(',').length == 2) {
|
var locations = query.term.match(/[+-]?\d+\.\d+,[+-]?\d+\.\d+/g);
|
||||||
var ll = query.term.split(',');
|
var added = {};
|
||||||
if(!isNaN(ll[0]) && !isNaN(ll[1])) {
|
locations.forEach(function(location) {
|
||||||
|
var pair = location.split(',').map(function(s) { return parseFloat(s).toFixed(6); });
|
||||||
|
var ll = pair.join(",");
|
||||||
|
var latlng = L.latLng(pair.map(function(s) { return parseFloat(s); }));
|
||||||
|
if(added[ll]) return;
|
||||||
|
added[ll] = true;
|
||||||
|
|
||||||
query.addResult({
|
query.addResult({
|
||||||
title: query.term,
|
title: ll,
|
||||||
description: 'geo coordinates',
|
description: 'geo coordinates',
|
||||||
position: L.latLng(parseFloat(ll[0]), parseFloat(ll[1])),
|
position: latlng,
|
||||||
|
onSelected: function(result, event) {
|
||||||
|
for(var guid in window.portals) {
|
||||||
|
var p = window.portals[guid].getLatLng();
|
||||||
|
if((p.lat.toFixed(6)+","+p.lng.toFixed(6)) == ll) {
|
||||||
|
renderPortalDetails(guid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
urlPortalLL = [result.position.lat, result.position.lng];
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// search on OpenStreetMap
|
||||||
addHook('search', function(query) {
|
addHook('search', function(query) {
|
||||||
if(!query.confirmed) return;
|
if(!query.confirmed) return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user