mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Fixes #801: Replaced freegeoip which is no longer free with ip-api
This commit is contained in:
parent
861387707a
commit
6a6ee280c3
@ -8,17 +8,19 @@ class GeolocationNode {
|
||||
|
||||
const ip = await netUtils.ip();
|
||||
|
||||
let response = await shim.fetch('https://freegeoip.net/json/' + ip);
|
||||
let response = await shim.fetch('http://ip-api.com/json/' + ip);
|
||||
if (!response.ok) throw new Error('Could not get geolocation: ' + await response.text());
|
||||
|
||||
response = await response.json();
|
||||
|
||||
if (!('lat' in response) || !('lon' in response)) throw new Error('Invalid geolocation response: ' . JSON.stringify(response));
|
||||
|
||||
return {
|
||||
timestamp: (new Date()).getTime(),
|
||||
coords: {
|
||||
longitude: response.longitude,
|
||||
longitude: response.lon,
|
||||
altitude: 0,
|
||||
latitude: response.latitude
|
||||
latitude: response.lat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ class Note extends BaseItem {
|
||||
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude is missing');
|
||||
if (!Number(note.latitude) && !Number(note.longitude)) throw new Error(_('This note does not have geolocation information.'));
|
||||
return this.geoLocationUrlFromLatLong(note.latitude, note.longitude);
|
||||
//return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude);
|
||||
}
|
||||
|
||||
static geoLocationUrlFromLatLong(lat, long) {
|
||||
|
Loading…
Reference in New Issue
Block a user