mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-22 02:34:01 +08:00
feat(nativegeocoder): add NativeGeocoder plugin (#800)
This commit is contained in:
parent
db55342329
commit
911537b61b
@ -70,6 +70,7 @@ import { LocalNotifications } from './plugins/localnotifications';
|
|||||||
import { LocationAccuracy } from './plugins/location-accuracy';
|
import { LocationAccuracy } from './plugins/location-accuracy';
|
||||||
import { MediaCapture } from './plugins/media-capture';
|
import { MediaCapture } from './plugins/media-capture';
|
||||||
import { NativeAudio } from './plugins/native-audio';
|
import { NativeAudio } from './plugins/native-audio';
|
||||||
|
import { NativeGeocoder } from './plugins/native-geocoder';
|
||||||
import { NativePageTransitions } from './plugins/native-page-transitions';
|
import { NativePageTransitions } from './plugins/native-page-transitions';
|
||||||
import { NativeStorage } from './plugins/nativestorage';
|
import { NativeStorage } from './plugins/nativestorage';
|
||||||
import { Market } from './plugins/market';
|
import { Market } from './plugins/market';
|
||||||
@ -183,6 +184,7 @@ export * from './plugins/media-capture';
|
|||||||
export * from './plugins/mixpanel';
|
export * from './plugins/mixpanel';
|
||||||
export * from './plugins/music-controls';
|
export * from './plugins/music-controls';
|
||||||
export * from './plugins/native-audio';
|
export * from './plugins/native-audio';
|
||||||
|
export * from './plugins/native-geocoder';
|
||||||
export * from './plugins/native-page-transitions';
|
export * from './plugins/native-page-transitions';
|
||||||
export * from './plugins/nativestorage';
|
export * from './plugins/nativestorage';
|
||||||
export * from './plugins/network';
|
export * from './plugins/network';
|
||||||
@ -293,6 +295,7 @@ window['IonicNative'] = {
|
|||||||
Mixpanel,
|
Mixpanel,
|
||||||
MusicControls,
|
MusicControls,
|
||||||
NativeAudio,
|
NativeAudio,
|
||||||
|
NativeGeocoder,
|
||||||
NativePageTransitions,
|
NativePageTransitions,
|
||||||
NativeStorage,
|
NativeStorage,
|
||||||
Network,
|
Network,
|
||||||
|
90
src/plugins/native-geocoder.ts
Normal file
90
src/plugins/native-geocoder.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Plugin, Cordova } from './plugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name NativeGeocoder
|
||||||
|
* @description
|
||||||
|
* Cordova plugin for native forward and reverse geocoding
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```typescript
|
||||||
|
* import { NativeGeocoder } from 'ionic-native';
|
||||||
|
*
|
||||||
|
* NativeGeocoder.reverseGeocode(52.5072095, 13.1452818)
|
||||||
|
* .then((result: ReverseResult) => console.log("The address is " + result.address + " in " + result.countryCode))
|
||||||
|
* .catch((error: any) => console.log(error));
|
||||||
|
*
|
||||||
|
* NativeGeocoder.forwardGeocode("Berlin")
|
||||||
|
* .then((coordinates: ForwardResult) => console.log("The coordinates are latitude=" + coordinates.latitude + " and longitude=" + coordinates.longitude))
|
||||||
|
* .catch((error: any) => console.log(error));
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
name: 'NativeGeocoder',
|
||||||
|
plugin: 'cordova-plugin-nativegeocoder',
|
||||||
|
pluginRef: 'nativegeocoder',
|
||||||
|
repo: 'https://github.com/sebastianbaar/cordova-plugin-nativegeocoder',
|
||||||
|
platforms: ['iOS', 'Android']
|
||||||
|
})
|
||||||
|
export class NativeGeocoder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse geocode a given latitude and longitude to find location address
|
||||||
|
* @param latitude {number} The latitude
|
||||||
|
* @param longitude {number} The longitude
|
||||||
|
* @return {Promise<any>}
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static reverseGeocode(latitude: number, longitude: number): Promise<ReverseResult> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forward geocode a given address to find coordinates
|
||||||
|
* @param addressString {string} The address to be geocoded
|
||||||
|
* @return {Promise<any>}
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static forwardGeocode(addressString: string): Promise<ForwardResult> { return; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulates format information about a reverse geocoding result.
|
||||||
|
*/
|
||||||
|
export interface ReverseResult {
|
||||||
|
/**
|
||||||
|
* The street.
|
||||||
|
*/
|
||||||
|
street: string;
|
||||||
|
/**
|
||||||
|
* The house number.
|
||||||
|
*/
|
||||||
|
houseNumber: string;
|
||||||
|
/**
|
||||||
|
* The postal code.
|
||||||
|
*/
|
||||||
|
postalCode: string;
|
||||||
|
/**
|
||||||
|
* The city.
|
||||||
|
*/
|
||||||
|
city: string;
|
||||||
|
/**
|
||||||
|
* The country name.
|
||||||
|
*/
|
||||||
|
countryName: string;
|
||||||
|
/**
|
||||||
|
* The country code.
|
||||||
|
*/
|
||||||
|
countryCode: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Encapsulates format information about a forward geocoding result.
|
||||||
|
*/
|
||||||
|
export interface ForwardResult {
|
||||||
|
/**
|
||||||
|
* The latitude.
|
||||||
|
*/
|
||||||
|
latitude: string;
|
||||||
|
/**
|
||||||
|
* The longitude.
|
||||||
|
*/
|
||||||
|
longitude: string;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user