master: change repo

This commit is contained in:
Julien Calixte
2019-08-22 11:50:32 +02:00
commit dbd63d341c
263 changed files with 26153 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import ILocation from '@/models/ILocation'
import ILocationQuery from '@/models/ILocationQuery'
class MapService {
private key: string = process.env.VUE_APP_MAP_KEY || ''
public async getLocation(location: ILocation): Promise<string> {
const result = await fetch(this.url(location.lat, location.lon))
if (!result) {
return ''
}
const json: ILocationQuery = await result.json()
if (
!json ||
!json.resourceSets ||
!json.resourceSets.length ||
!json.resourceSets[0].resources.length
) {
return ''
}
const address = json.resourceSets[0].resources[0].address
return address ? address.locality : ''
}
private url(latitude: number, longitude: number) {
return `https://dev.virtualearth.net/REST/v1/Locations/${latitude},${longitude}?key=${
this.key
}`
}
}
export default new MapService()