From 05b1d44990fd77460a258b91a2f7a88eafaab11a Mon Sep 17 00:00:00 2001 From: Sebastian Baar Date: Thu, 17 Nov 2016 14:34:29 +0100 Subject: [PATCH 1/5] feat(nativegeocoder): add NativeGeocoder plugin --- src/index.ts | 3 ++ src/plugins/native-geocoder.ts | 90 ++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/plugins/native-geocoder.ts diff --git a/src/index.ts b/src/index.ts index 8b8d55f6c2..dc565149a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,6 +70,7 @@ import { LocalNotifications } from './plugins/localnotifications'; import { LocationAccuracy } from './plugins/location-accuracy'; import { MediaCapture } from './plugins/media-capture'; import { NativeAudio } from './plugins/native-audio'; +import { NativeGeocoder } from './plugins/native-geocoder'; import { NativePageTransitions } from './plugins/native-page-transitions'; import { NativeStorage } from './plugins/nativestorage'; import { Market } from './plugins/market'; @@ -183,6 +184,7 @@ export * from './plugins/media-capture'; export * from './plugins/mixpanel'; export * from './plugins/music-controls'; export * from './plugins/native-audio'; +export * from './plugins/native-geocoder'; export * from './plugins/native-page-transitions'; export * from './plugins/nativestorage'; export * from './plugins/network'; @@ -293,6 +295,7 @@ window['IonicNative'] = { Mixpanel, MusicControls, NativeAudio, + NativeGeocoder, NativePageTransitions, NativeStorage, Network, diff --git a/src/plugins/native-geocoder.ts b/src/plugins/native-geocoder.ts new file mode 100644 index 0000000000..c5d0450cff --- /dev/null +++ b/src/plugins/native-geocoder.ts @@ -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} + */ + @Cordova() + static reverseGeocode(latitude: number, longitude: number): Promise { return; } + + /** + * Forward geocode a given address to find coordinates + * @param addressString {string} The address to be geocoded + * @return {Promise} + */ + @Cordova() + static forwardGeocode(addressString: string): Promise { 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; +} From 51c4de3aab78df01a1299a1da5e10af83a10820d Mon Sep 17 00:00:00 2001 From: Sebastian Baar Date: Sun, 16 Apr 2017 18:22:24 +0200 Subject: [PATCH 2/5] add district --- src/@ionic-native/plugins/native-geocoder/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/@ionic-native/plugins/native-geocoder/index.ts b/src/@ionic-native/plugins/native-geocoder/index.ts index 19e9ef7b10..1a281d8537 100644 --- a/src/@ionic-native/plugins/native-geocoder/index.ts +++ b/src/@ionic-native/plugins/native-geocoder/index.ts @@ -80,6 +80,10 @@ export interface NativeGeocoderReverseResult { * The city. */ city: string; + /** + * The district (subLocality). + */ + district: string; /** * The country name. */ From 88c3726e80cceb4e8f303ba5030d4c36b5edb6ab Mon Sep 17 00:00:00 2001 From: Sebastian Baar Date: Wed, 26 Jul 2017 11:04:06 +0200 Subject: [PATCH 3/5] update NativeGeocoderReverseResult & refactor code --- .../plugins/native-geocoder/index.ts | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/@ionic-native/plugins/native-geocoder/index.ts b/src/@ionic-native/plugins/native-geocoder/index.ts index 278e4660cd..176be80279 100644 --- a/src/@ionic-native/plugins/native-geocoder/index.ts +++ b/src/@ionic-native/plugins/native-geocoder/index.ts @@ -15,7 +15,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; * ... * * this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818) - * .then((result: NativeGeocoderReverseResult) => console.log('The address is ' + result.street + ' in ' + result.countryCode)) + * .then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result))) * .catch((error: any) => console.log(error)); * * this.nativeGeocoder.forwardGeocode('Berlin') @@ -40,7 +40,7 @@ export class NativeGeocoder extends IonicNativePlugin { * Reverse geocode a given latitude and longitude to find location address * @param latitude {number} The latitude * @param longitude {number} The longitude - * @return {Promise} + * @return {Promise} */ @Cordova({ callbackOrder: 'reverse' @@ -50,52 +50,59 @@ export class NativeGeocoder extends IonicNativePlugin { /** * Forward geocode a given address to find coordinates * @param addressString {string} The address to be geocoded - * @return {Promise} + * @return {Promise} */ @Cordova({ callbackOrder: 'reverse' }) forwardGeocode(addressString: string): Promise { return; } - } /** * Encapsulates format information about a reverse geocoding result. + * more Info: + * - https://developer.apple.com/documentation/corelocation/clplacemark + * - https://developer.android.com/reference/android/location/Address.html */ export interface NativeGeocoderReverseResult { /** - * The street. + * The country code. */ - street: string; + countryCode: string; /** - * The house number. + * The country name. */ - houseNumber: string; + countryName: string; /** * The postal code. */ postalCode: string; /** - * The city. + * The administrativeArea. */ - city: string; + administrativeArea: string; /** -<<<<<<< HEAD - * The district (subLocality). -======= - * The district. ->>>>>>> ionic-team/master + * The subAdministrativeArea. */ - district: string; + subAdministrativeArea: string; /** - * The country name. + * The locality. */ - countryName: string; + locality: string; /** - * The country code. + * The subLocality. */ - countryCode: string; + subLocality: string; + /** + * The thoroughfare. + */ + thoroughfare: string; + /** + * The subThoroughfare. + */ + subThoroughfare: string; } + /** * Encapsulates format information about a forward geocoding result. */ From 0401606a4110e0f9104e3d3571ffff930fc5c73a Mon Sep 17 00:00:00 2001 From: Sebastian Baar Date: Wed, 26 Jul 2017 11:07:38 +0200 Subject: [PATCH 4/5] delete plugins --- src/plugins/native-geocoder.ts | 90 ---------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/plugins/native-geocoder.ts diff --git a/src/plugins/native-geocoder.ts b/src/plugins/native-geocoder.ts deleted file mode 100644 index c5d0450cff..0000000000 --- a/src/plugins/native-geocoder.ts +++ /dev/null @@ -1,90 +0,0 @@ -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} - */ - @Cordova() - static reverseGeocode(latitude: number, longitude: number): Promise { return; } - - /** - * Forward geocode a given address to find coordinates - * @param addressString {string} The address to be geocoded - * @return {Promise} - */ - @Cordova() - static forwardGeocode(addressString: string): Promise { 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; -} From 1ba8a3da361144674ae363e34656070568acf0e8 Mon Sep 17 00:00:00 2001 From: Sebastian Baar Date: Wed, 26 Jul 2017 11:12:21 +0200 Subject: [PATCH 5/5] delete index.ts --- src/index.ts | 358 --------------------------------------------------- 1 file changed, 358 deletions(-) delete mode 100644 src/index.ts diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index dc565149a1..0000000000 --- a/src/index.ts +++ /dev/null @@ -1,358 +0,0 @@ -import { initAngular1 } from './ng1'; - -const DEVICE_READY_TIMEOUT = 2000; - -declare var window; - -import { ActionSheet } from './plugins/actionsheet'; -import { AdMob } from './plugins/admob'; -import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth'; -import { AppAvailability } from './plugins/appavailability'; -import { AppRate } from './plugins/apprate'; -import { AppVersion } from './plugins/appversion'; -import { Badge } from './plugins/badge'; -import { BackgroundGeolocation } from './plugins/background-geolocation'; -import { BackgroundMode } from './plugins/backgroundmode'; -import { BarcodeScanner } from './plugins/barcodescanner'; -import { Base64ToGallery } from './plugins/base64togallery'; -import { BatteryStatus } from './plugins/batterystatus'; -import { Brightness } from './plugins/brightness'; -import { BLE } from './plugins/ble'; -import { BluetoothSerial } from './plugins/bluetoothserial'; -import { Calendar } from './plugins/calendar'; -import { CallNumber } from './plugins/call-number'; -import { Camera } from './plugins/camera'; -import { CameraPreview } from './plugins/camera-preview'; -import { CardIO } from './plugins/card-io'; -import { Clipboard } from './plugins/clipboard'; -import { CodePush } from './plugins/code-push'; -import { Contacts } from './plugins/contacts'; -import { Crop } from './plugins/crop'; -import { DatePicker } from './plugins/datepicker'; -import { DBMeter } from './plugins/dbmeter'; -import { Deeplinks } from './plugins/deeplinks'; -import { Device } from './plugins/device'; -import { DeviceFeedback } from './plugins/device-feedback'; -import { DeviceAccounts } from './plugins/deviceaccounts'; -import { DeviceMotion } from './plugins/devicemotion'; -import { DeviceOrientation } from './plugins/deviceorientation'; -import { Diagnostic } from './plugins/diagnostic'; -import { Dialogs } from './plugins/dialogs'; -import { EmailComposer } from './plugins/emailcomposer'; -import { EstimoteBeacons } from './plugins/estimote-beacons'; -import { Facebook } from './plugins/facebook'; -import { File } from './plugins/file'; -import { FileChooser } from './plugins/file-chooser'; -import { FileOpener } from './plugins/file-opener'; -import { FilePath } from './plugins/filepath'; -import { Transfer } from './plugins/filetransfer'; -import { Flashlight } from './plugins/flashlight'; -import { Geofence } from './plugins/geofence'; -import { Geolocation } from './plugins/geolocation'; -import { Globalization } from './plugins/globalization'; -import { GooglePlus } from './plugins/google-plus'; -import { GoogleMap } from './plugins/googlemap'; -import { GoogleAnalytics } from './plugins/googleanalytics'; -import { Hotspot } from './plugins/hotspot'; -import { HTTP } from './plugins/http'; -import { Httpd } from './plugins/httpd'; -import { IBeacon } from './plugins/ibeacon'; -import { ImagePicker } from './plugins/imagepicker'; -import { ImageResizer } from './plugins/imageresizer'; -import { InAppBrowser } from './plugins/inappbrowser'; -import { InAppPurchase } from './plugins/inapppurchase'; -import { Insomnia } from './plugins/insomnia'; -import { Instagram } from './plugins/instagram'; -import { IsDebug } from './plugins/is-debug'; -import { Keyboard } from './plugins/keyboard'; -import { LaunchNavigator } from './plugins/launchnavigator'; -import { LocalNotifications } from './plugins/localnotifications'; -import { LocationAccuracy } from './plugins/location-accuracy'; -import { MediaCapture } from './plugins/media-capture'; -import { NativeAudio } from './plugins/native-audio'; -import { NativeGeocoder } from './plugins/native-geocoder'; -import { NativePageTransitions } from './plugins/native-page-transitions'; -import { NativeStorage } from './plugins/nativestorage'; -import { Market } from './plugins/market'; -import { MediaPlugin } from './plugins/media'; -import { Mixpanel } from './plugins/mixpanel'; -import { MusicControls } from './plugins/music-controls'; -import { Network } from './plugins/network'; -import { NFC } from './plugins/nfc'; -import { OneSignal } from './plugins/onesignal'; -import { PhotoViewer } from './plugins/photo-viewer'; -import { ScreenOrientation } from './plugins/screen-orientation'; -import { PayPal } from './plugins/pay-pal'; -import { PinDialog } from './plugins/pin-dialog'; -import { PowerManagement } from './plugins/power-management'; -import { Printer } from './plugins/printer'; -import { Push } from './plugins/push'; -import { SafariViewController } from './plugins/safari-view-controller'; -import { Screenshot } from './plugins/screenshot'; -import { SecureStorage } from './plugins/securestorage'; -import { Shake } from './plugins/shake'; -import { Sim } from './plugins/sim'; -import { SMS } from './plugins/sms'; -import { SocialSharing } from './plugins/socialsharing'; -import { SpinnerDialog } from './plugins/spinnerdialog'; -import { Splashscreen } from './plugins/splashscreen'; -import { SQLite } from './plugins/sqlite'; -import { StatusBar } from './plugins/statusbar'; -import { Stepcounter } from './plugins/stepcounter'; -import { StreamingMedia } from './plugins/streaming-media'; -import { ThreeDeeTouch } from './plugins/3dtouch'; -import { Toast } from './plugins/toast'; -import { TouchID } from './plugins/touchid'; -import { TextToSpeech } from './plugins/text-to-speech'; -import { ThemeableBrowser } from './plugins/themeable-browser'; -import { TwitterConnect } from './plugins/twitter-connect'; -import { Vibration } from './plugins/vibration'; -import { VideoEditor } from './plugins/video-editor'; -import { VideoPlayer } from './plugins/video-player'; -import { WebIntent } from './plugins/webintent'; -import { YoutubeVideoPlayer } from './plugins/youtube-video-player'; -import { ZBar } from './plugins/z-bar'; -import { Zip } from './plugins/zip'; -export * from './plugins/3dtouch'; -export * from './plugins/actionsheet'; -export * from './plugins/admob'; -export * from './plugins/android-fingerprint-auth'; -export * from './plugins/appavailability'; -export * from './plugins/apprate'; -export * from './plugins/appversion'; -export * from './plugins/background-geolocation'; -export * from './plugins/backgroundmode'; -export * from './plugins/badge'; -export * from './plugins/barcodescanner'; -export * from './plugins/base64togallery'; -export * from './plugins/batterystatus'; -export * from './plugins/ble'; -export * from './plugins/bluetoothserial'; -export * from './plugins/brightness'; -export * from './plugins/calendar'; -export * from './plugins/call-number'; -export * from './plugins/camera'; -export * from './plugins/camera-preview'; -export * from './plugins/card-io'; -export * from './plugins/clipboard'; -export * from './plugins/code-push'; -export * from './plugins/contacts'; -export * from './plugins/crop'; -export * from './plugins/datepicker'; -export * from './plugins/dbmeter'; -export * from './plugins/deeplinks'; -export * from './plugins/device'; -export * from './plugins/device-feedback'; -export * from './plugins/deviceaccounts'; -export * from './plugins/devicemotion'; -export * from './plugins/deviceorientation'; -export * from './plugins/diagnostic'; -export * from './plugins/dialogs'; -export * from './plugins/emailcomposer'; -export * from './plugins/estimote-beacons'; -export * from './plugins/facebook'; -export * from './plugins/file'; -export * from './plugins/file-chooser'; -export * from './plugins/file-opener'; -export * from './plugins/filetransfer'; -export * from './plugins/filepath'; -export * from './plugins/flashlight'; -export * from './plugins/geofence'; -export * from './plugins/geolocation'; -export * from './plugins/globalization'; -export * from './plugins/google-plus'; -export * from './plugins/googleanalytics'; -export * from './plugins/googlemap'; -export * from './plugins/hotspot'; -export * from './plugins/http'; -export * from './plugins/httpd'; -export * from './plugins/ibeacon'; -export * from './plugins/imagepicker'; -export * from './plugins/imageresizer'; -export * from './plugins/inappbrowser'; -export * from './plugins/inapppurchase'; -export * from './plugins/insomnia'; -export * from './plugins/instagram'; -export * from './plugins/is-debug'; -export * from './plugins/keyboard'; -export * from './plugins/launchnavigator'; -export * from './plugins/localnotifications'; -export * from './plugins/location-accuracy'; -export * from './plugins/market'; -export * from './plugins/media'; -export * from './plugins/media-capture'; -export * from './plugins/mixpanel'; -export * from './plugins/music-controls'; -export * from './plugins/native-audio'; -export * from './plugins/native-geocoder'; -export * from './plugins/native-page-transitions'; -export * from './plugins/nativestorage'; -export * from './plugins/network'; -export * from './plugins/nfc'; -export * from './plugins/onesignal'; -export * from './plugins/pay-pal'; -export * from './plugins/photo-viewer'; -export * from './plugins/pin-dialog'; -export * from './plugins/plugin'; -export * from './plugins/power-management'; -export * from './plugins/printer'; -export * from './plugins/push'; -export * from './plugins/safari-view-controller'; -export * from './plugins/screen-orientation'; -export * from './plugins/screenshot'; -export * from './plugins/securestorage'; -export * from './plugins/shake'; -export * from './plugins/sim'; -export * from './plugins/sms'; -export * from './plugins/socialsharing'; -export * from './plugins/spinnerdialog'; -export * from './plugins/splashscreen'; -export * from './plugins/sqlite'; -export * from './plugins/statusbar'; -export * from './plugins/stepcounter'; -export * from './plugins/streaming-media'; -export * from './plugins/text-to-speech'; -export * from './plugins/themeable-browser'; -export * from './plugins/toast'; -export * from './plugins/touchid'; -export * from './plugins/twitter-connect'; -export * from './plugins/vibration'; -export * from './plugins/video-editor'; -export * from './plugins/video-player'; -export * from './plugins/webintent'; -export * from './plugins/youtube-video-player'; -export * from './plugins/z-bar'; -export * from './plugins/zip'; - -// Window export to use outside of a module loading system -window['IonicNative'] = { - ActionSheet, - AdMob, - AndroidFingerprintAuth, - AppAvailability, - AppRate, - AppVersion, - Badge, - BackgroundGeolocation, - BackgroundMode, - BarcodeScanner, - Base64ToGallery, - BatteryStatus, - Brightness, - BLE, - BluetoothSerial, - Calendar, - CallNumber, - Camera, - CameraPreview, - CardIO, - Clipboard, - CodePush, - Contacts, - Crop, - DatePicker, - DBMeter, - Deeplinks, - Device, - DeviceFeedback, - DeviceAccounts, - DeviceMotion, - DeviceOrientation, - Dialogs, - Diagnostic, - EmailComposer, - EstimoteBeacons, - Facebook, - File, - FileChooser, - FileOpener, - FilePath, - Flashlight, - Geofence, - Geolocation, - Globalization, - GooglePlus, - GoogleMap, - GoogleAnalytics, - Hotspot, - HTTP, - Httpd, - IBeacon, - ImagePicker, - ImageResizer, - InAppBrowser, - InAppPurchase, - Insomnia, - Instagram, - IsDebug, - Keyboard, - LaunchNavigator, - LocalNotifications, - LocationAccuracy, - Market, - MediaCapture, - MediaPlugin, - Mixpanel, - MusicControls, - NativeAudio, - NativeGeocoder, - NativePageTransitions, - NativeStorage, - Network, - PayPal, - NFC, - Printer, - Push, - OneSignal, - PhotoViewer, - ScreenOrientation, - PinDialog, - PowerManagement, - SafariViewController, - Screenshot, - SecureStorage, - Shake, - Sim, - SMS, - SocialSharing, - SpinnerDialog, - Splashscreen, - SQLite, - StatusBar, - Stepcounter, - StreamingMedia, - ThreeDeeTouch, - Toast, - TouchID, - Transfer, - TextToSpeech, - ThemeableBrowser, - TwitterConnect, - VideoEditor, - VideoPlayer, - Vibration, - WebIntent, - YoutubeVideoPlayer, - ZBar, - Zip -}; - -initAngular1(window['IonicNative']); - -// To help developers using cordova, we listen for the device ready event and -// log an error if it didn't fire in a reasonable amount of time. Generally, -// when this happens, developers should remove and reinstall plugins, since -// an inconsistent plugin is often the culprit. -const before = Date.now(); - -let didFireReady = false; -document.addEventListener('deviceready', () => { - console.log('DEVICE READY FIRED AFTER', (Date.now() - before), 'ms'); - didFireReady = true; -}); - -setTimeout(() => { - if (!didFireReady && window.cordova) { - console.warn(`Native: deviceready did not fire within ${DEVICE_READY_TIMEOUT}ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.`); - } -}, DEVICE_READY_TIMEOUT);