parent
b5a2ffc6a5
commit
2996da65c3
@ -1005,3 +1005,38 @@ export class GoogleMapsLatLng {
|
|||||||
return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision);
|
return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export interface GeocoderRequest {
|
||||||
|
address?: string;
|
||||||
|
position?: {lat: number; lng: number};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export interface GeocoderResult {
|
||||||
|
position?: {lat: number; lng: number};
|
||||||
|
subThoroughfare?: string;
|
||||||
|
thoroughfare?: string;
|
||||||
|
locality?: string;
|
||||||
|
adminArea?: string;
|
||||||
|
postalCode?: string;
|
||||||
|
country?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export class Geocoder {
|
||||||
|
/**
|
||||||
|
* Converts position to address and vice versa
|
||||||
|
* @param {GeocoderRequest} request Request object with either an address or a position
|
||||||
|
* @returns {Promise<GeocoderResult[]>}
|
||||||
|
*/
|
||||||
|
static geocode(request: GeocoderRequest): Promise<GeocoderResult[]> {
|
||||||
|
return new Promise<GeocoderResult[]>((resolve, reject) => {
|
||||||
|
if (!plugin || !plugin.google || !plugin.google.maps || !plugin.google.maps.Geocoder) reject({error: 'plugin_not_installed'});
|
||||||
|
else plugin.google.maps.Geocoder.geocode(request, resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user