Display location on map node details

This commit is contained in:
maciejhirsz
2018-07-18 16:59:47 +02:00
parent 3696d7c46e
commit 5c1480f9f5
11 changed files with 30 additions and 17 deletions
+5 -3
View File
@@ -4,6 +4,7 @@ import { Maybe, Types } from '@dotstats/common';
export interface Location {
lat: Types.Latitude;
lon: Types.Longitude;
city: Types.City;
}
const cache = new Map<string, Location>();
@@ -12,7 +13,8 @@ export async function locate(ip: string): Promise<Maybe<Location>> {
if (ip === '127.0.0.1') {
return Promise.resolve({
lat: 52.5166667 as Types.Latitude,
lon: 13.4 as Types.Longitude
lon: 13.4 as Types.Longitude,
city: 'Berlin' as Types.City,
});
}
@@ -30,8 +32,8 @@ export async function locate(ip: string): Promise<Maybe<Location>> {
return resolve(null);
}
const { latitude: lat, longitude: lon } = result;
const location = { lat, lon } as Location;
const { latitude: lat, longitude: lon, city } = result;
const location = { lat, lon, city } as Location;
cache.set(ip, location);