{"_id":"@comingzones/cordova-plugin-gaodelocation-chenyu","name":"@comingzones/cordova-plugin-gaodelocation-chenyu","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@comingzones/cordova-plugin-gaodelocation-chenyu","version":"1.0.0","description":"Cordova Device Plugin","types":"./types/index.d.ts","cordova":{"id":"@comingzones/cordova-plugin-gaodelocation-chenyu","platforms":["android","ios","windows","browser","osx"]},"repository":{"type":"git","url":"git+ssh://git@github.com/comingzones/cordova-plugin-device.git"},"keywords":["cordova","device","ecosystem:cordova","cordova-android","cordova-ios","cordova-windows","cordova-browser","cordova-osx"],"scripts":{"test":"npm run eslint","eslint":"node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"},"author":{"name":"dev@comingzones.com"},"gitHead":"a07f8ba376d5014fe9f5c40d36b721f9eb18632a","bugs":{"url":"https://github.com/comingzones/cordova-plugin-device/issues"},"homepage":"https://github.com/comingzones/cordova-plugin-device#readme","_id":"@comingzones/cordova-plugin-gaodelocation-chenyu@1.0.0","_nodeVersion":"15.8.0","_npmVersion":"7.5.1","dist":{"integrity":"sha512-6P36KvBYSNQZellxwWUrr170K7Of1BFiZk/aA7FEpqJo26x/xGVSRweXRfgS5hZoV9clz5Wp4aUSr5IxkAWdqg==","shasum":"240d1ea28c6f28ac06e4afcb189b1716a73d6c5b","tarball":"https://registry.npmjs.org/@comingzones/cordova-plugin-gaodelocation-chenyu/-/cordova-plugin-gaodelocation-chenyu-1.0.0.tgz","fileCount":239,"unpackedSize":148297180,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDk2ji+pMO1INUpAQv3tSarG66TWSFttXsahgaqYYTAjQIhAICf3fjhtWDdTugrp2Kq9KcR0jCl5oWh2TVPe9E6eAuP"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjDYTlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoLOg//UdJ5qi3jy/IhVK/2pt/lUnIceY8ruVyqCDDy8qS33GHcp1Ce\r\nHp0e5Uxy3Rd0y4JVapuO7lRo7nx+ueOknrMs4iHkPgfgPBAkosk5tayoGMsJ\r\nvIea6v9PCrVxwYiau0CgavboVyLL8EQ/N/9bA4fM+rtvjsksS/1jOkH9ESlo\r\n4E3+pCyghfjoAIFk20k6mfwndsKzL2JdgtmPep97oceF+V7P4nk+j7do9gZO\r\nf+EM1b09WIXF2E0gVfRGACQsOQAfZeenp4u1o1zm9swutvVjZmIM9ig4Kn8L\r\nW9m99CfIyWepN1XfsGuvzbvQ5bCWxSuSr6EClwUY9LP+rTsLsxv6aXj5XH1C\r\nMFZI1UvIsWlhfMQbLXO5aFZBX9JL/Rjl1RY1mS9fdovfDqGllRgYlGtJPmA9\r\nd9qOP2GCkjSDkf07sYE0ZiebDXWMQzakyd06IffeUutuMt/R3O3FSq2N6qyO\r\n0ZjV7ffEWSTVsgJSCo/rFbFme9bv/Nlvga7YSh/BPWN2xnIpU4L7g24tZb7L\r\nPT5qBxYnUH3rohBgpQpBylC/WeeI9ibIaB4IHs5cms6Cm0D+BumwIhhT+8Y1\r\nO1b+5iS8xbHccCezfzjVD+6pudtWEHWLGyoK6f9lIhZ4Uw7uxnn7audffjfa\r\nYpnJ8vWm85ivkF+xYCjTzlopWDHCFu50EhA=\r\n=M2d/\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"comingzones2020","email":"darrenhou1993@gmail.com"},"directories":{},"maintainers":[{"name":"comingzones2020","email":"darrenhou1993@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cordova-plugin-gaodelocation-chenyu_1.0.0_1661830372208_0.1554735093105717"},"_hasShrinkwrap":false}},"time":{"created":"2022-08-30T03:32:52.126Z","1.0.0":"2022-08-30T03:32:53.271Z","modified":"2022-08-30T03:32:53.432Z"},"maintainers":[{"name":"comingzones2020","email":"darrenhou1993@gmail.com"}],"description":"Cordova Device Plugin","homepage":"https://github.com/comingzones/cordova-plugin-device#readme","keywords":["cordova","device","ecosystem:cordova","cordova-android","cordova-ios","cordova-windows","cordova-browser","cordova-osx"],"repository":{"type":"git","url":"git+ssh://git@github.com/comingzones/cordova-plugin-device.git"},"author":{"name":"dev@comingzones.com"},"bugs":{"url":"https://github.com/comingzones/cordova-plugin-device/issues"},"readme":"### 高德地图定位 \r\n\r\n插件环境 cordova-android >= 7.0.0\r\n\r\n#### 基础功能\r\n\r\n- [x] 单次定位\r\n- [x] 持续定位\r\n\r\n#### 1.申请密钥\r\n请参照：\r\n<br>\r\n[申请android密钥定位SDK](http://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key/)\r\n<br>\r\n[申请ios密钥定位SDK](https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key)\r\n#### 2.安装插件\r\n\r\n\r\n\r\n```bash\r\n# 1.通过npm 安装 \r\n\r\ncordova plugin add cordova-plugin-gaodelocation-chenyu --variable  ANDROID_API_KEY=your android key --variable  IOS_API_KEY=your ios key\r\n\r\nnpm install --save @ionic-native/gao-de-location\r\n\r\n# 2.通过github安装 \r\ncordova plugin add https://github.com/waliu/cordova-plugin-gaodelocation-chenyu  --variable  ANDROID_API_KEY=your android key --variable  IOS_API_KEY=your ios key\r\n\r\n# 3.或者本地安装\r\ncordova plugin add --link 文件路径  --variable ANDROID_API_KEY=your android key --variable  IOS_API_KEY=your ios key\r\n\r\n```\r\n\r\n\r\n\r\n#### 3.js/ts使用方法\r\n\r\n```typescript\r\n// 1.js项目调用\r\nwindow.GaoDe.getCurrentPosition(successCallback, failedCallback,option);\r\nwindow.GaoDe.startSerialLocation(successCallback, failedCallback,option);\r\nwindow.GaoDe.stopSerialLocation(successCallback, failedCallback);\r\n// 2.ts/ionic项目调用。\r\n(<any>window).GaoDe.getCurrentPosition(successCallback, failedCallback,option);\r\n(<any>window).GaoDe.startSerialLocation(successCallback, failedCallback,option);\r\n(<any>window).GaoDe.stopSerialLocation(successCallback, failedCallback);\r\n\r\n```\r\n\r\n\r\n②[ionic 版本调用方式](#Mark)\r\n#### 4.定位方法说明\r\n\r\n### 获取单次定位\r\n\r\n> getCurrentPosition(successCallback,failedCallback,option);\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nsuccessCallback|funtion|回调函数\r\nfailedCallback|funtion|回调函数\r\noption|PositionOption|定位参数\r\n\r\n### <font color=red>PositionOption</font>\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nandroidOption|androidOption|android定位参数\r\niosOption|iosOption|ios定位参数\r\n\r\n### androidOption\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nlocationMode|Number|1.精确定位 2.仅设备定位模式；3.低功耗定位模式\r\ngpsFirst|Boolean|设置是否gps优先，只在高精度模式下有效。默认关闭\r\nHttpTimeOut|Number|设置网络请求超时时间。默认为30秒。在仅设备模式下无效\r\ninterval|Number|设置定位间隔。默认为2秒 连续定位有效\r\nneedAddress|Boolean|设置是否返回逆地理地址信息。默认是true\r\nonceLocation|Boolean|设置是否单次定位。默认是false\r\nonceLocationLatest|Boolean|设置是否等待wifi刷新，默认为false.如果设置为true,会自动变为单次定位，持续定位时不要使用\r\nlocationProtocol|Number|设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP。1.http 2.https\r\nsensorEnable|Boolean|设置是否使用传感器。默认是false\r\nwifiScan|Boolean|设置是否开启wifi扫描。默认为true，如果设置为false会同时停止主动刷新，停止以后完全依赖于系统刷新，定位位置可能存在误差\r\nlocationCacheEnable|Boolean|设置是否使用缓存定位，默认为true\r\n\r\n### iosOption \r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\ndesiredAccuracy|Number|1.最适合导航用的定位  iOS4.0以后新增 2.精度最高的定位 3.定位精度在10米以内 4.定位精度在100米以内 5.定位精度在1000米以内 6.3000m以内\r\npausesLocationUpdatesAutomatically|String|指定定位是否会被系统自动暂停。默认为NO。\r\nallowsBackgroundLocationUpdates|String|是否允许后台定位。默认为NO。\r\nlocationTimeout|Number|指定单次定位超时时间,默认为10s。最小值是2s。\r\nreGeocodeTimeout|Number|指定单次定位逆地理超时时间,默认为5s。最小值是2s。\r\nlocatingWithReGeocode|String|是否启用逆地址定位 默认YES\r\n\r\n```typescript\r\n//调用实例\r\ngetCurrentPosition() {\r\n    let obj={\r\n      androidOption:{\r\n        locationMode:1,//定位精度 1.精确定位 2.仅设备定位模式；3.低功耗定位模式\r\n        gpsFirst:false,//设置是否gps优先，只在高精度模式下有效。默认关闭\r\n        HttpTimeOut:30000,//设置网络请求超时时间。默认为30秒。在仅设备模式下无效\r\n        interval:2000,//设置定位间隔。默认为2秒 连续定位有效\r\n        needAddress:true,//设置是否返回逆地理地址信息。默认是true\r\n        onceLocation:false,//设置是否单次定位。默认是false\r\n        onceLocationLatest:false,//设置是否等待wifi刷新，默认为false.如果设置为true,会自动变为单次定位，持续定位时不要使用\r\n        locationProtocol:1,// 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP。1.http 2.https\r\n        sensorEnable:false,//设置是否使用传感器。默认是false\r\n        wifiScan:true,//设置是否开启wifi扫描。默认为true，如果设置为false会同时停止主动刷新，停止以后完全依赖于系统刷新，定位位置可能存在误差\r\n        locationCacheEnable:true//设置是否使用缓存定位，默认为true\r\n      },\r\n      iosOption:{\r\n        desiredAccuracy:4,// 1。最适合导航用的定位  iOS4.0以后新增 2.精度最高的定位 3.定位精度在10米以内定位精度在10米以内 4.定位精度在100米以内 5.定位精度在1000米以内 6.3000m\r\n        pausesLocationUpdatesAutomatically:\"YES\",//指定定位是否会被系统自动暂停。默认为NO。\r\n        allowsBackgroundLocationUpdates:\"NO\",//是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态，否则会抛出异常。由于iOS系统限制，需要在定位未开始之前或定位停止之后，修改该属性的值才会有效果。\r\n        locationTimeout:10, //指定单次定位超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。注意: 单次定位超时时间从确定了定位权限(非kCLAuthorizationStatusNotDetermined状态)后开始计算\r\n        reGeocodeTimeout:5, //指定单次定位逆地理超时时间,默认为5s。最小值是2s。注意单次定位请求前设置。\r\n        locatingWithReGeocode:\"YES\" //是否 启用逆地址定位 默认YES\r\n      }\r\n    };\r\n    (<any>window).GaoDe.getCurrentPosition( (res) => {\r\n      console.log(JSON.stringify(res));\r\n    }, () => {\r\n\r\n    },obj);\r\n  }\r\n```\r\n\r\n开启持续定位\r\n\r\n> startSerialLocation(successCallback,failedCallback,option);\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nsuccessCallback|funtion|回调函数\r\nfailedCallback|funtion|回调函数\r\noption|PositionOption|定位参数\r\n\r\n### androidOption\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nlocationMode|Number|1.精确定位 2.仅设备定位模式；3.低功耗定位模式\r\ngpsFirst|Boolean|设置是否gps优先，只在高精度模式下有效。默认关闭\r\nHttpTimeOut|Number|设置网络请求超时时间。默认为30秒。在仅设备模式下无效\r\ninterval|Number|设置定位间隔。默认为2秒 连续定位有效\r\nneedAddress|Boolean|设置是否返回逆地理地址信息。默认是true\r\nonceLocation|Boolean|设置是否单次定位。默认是false\r\nonceLocationLatest|Boolean|设置是否等待wifi刷新，默认为false.如果设置为true,会自动变为单次定位，持续定位时不要使用\r\nlocationProtocol|Number|设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP。1.http 2.https\r\nsensorEnable|Boolean|设置是否使用传感器。默认是false\r\nwifiScan|Boolean|设置是否开启wifi扫描。默认为true，如果设置为false会同时停止主动刷新，停止以后完全依赖于系统刷新，定位位置可能存在误差\r\nlocationCacheEnable|Boolean|设置是否使用缓存定位，默认为true\r\n\r\n### iosOption \r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\npausesLocationUpdatesAutomatically|String|指定定位是否会被系统自动暂停。默认为NO。\r\nallowsBackgroundLocationUpdates|String|是否允许后台定位。默认为NO。\r\nlocatingWithReGeocode|String|是否启用逆地址定位 默认YES\r\n\r\n```typescript\r\nstartSerialLocation() {\r\n    let obj={\r\n      androidOption:{\r\n        locationMode:1,\r\n        gpsFirst:false,\r\n        HttpTimeOut:30000,\r\n        interval:2000,\r\n        needAddress:true,\r\n        onceLocation:false,\r\n        onceLocationLatest:false,\r\n        locationProtocol:1,\r\n        sensorEnable:false,\r\n        wifiScan:true,\r\n        locationCacheEnable:true\r\n      },\r\n      iosOption:{\r\n        pausesLocationUpdatesAutomatically:\"YES\",\r\n        allowsBackgroundLocationUpdates:\"NO\",\r\n        locatingWithReGeocode:\"YES\"\r\n      }\r\n    };\r\n    (<any>window).GaoDe.startSerialLocation( (res) => {\r\n      console.log(JSON.stringify(res));\r\n    }, (e) => {\r\n\r\n    },obj);\r\n  }\r\n```\r\n\r\n停止持续定位\r\n\r\n> stopSerialLocation(successCallback,failedCallback);\r\n\r\n参数|类型|说明\r\n| :----:| :----: | :----: |\r\nsuccessCallback|funtion|回调函数\r\nfailedCallback|funtion|回调函数\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#### 5.返回值说明:\r\n\r\n返回值字段|返回值类型|说明| android支持|ios支持\r\n| :----:| :----: | :----: |:----:|:----:|\r\nlatitude|string|获取纬度|√|√\r\nlongitude|string|获取经度|√|√\r\naccuracy|string|获取精度信息|√|√\r\nformattedAddress|string|获取地址描述|√|√\r\ncountry|string|获取国家名称|√|√\r\nprovince|string|获取省名称|√|√\r\ncity|string|获取城市名称|√|√\r\ndistrict|string|获取城区名称|√|√\r\ncitycode|string|获取城市编码信息|√|√\r\nadcode|string|获取区域编码信息|√|√\r\nstreet|string|获取街道名称|√|√\r\nnumber|string|街道门牌号信息|√|√\r\nPOIName|string|获取当前位置的POI名称|√|√\r\nAOIName|string|获取当前位置所处AOI名称|√|√\r\naltitude|string|获取海拔高度信息|√|×\r\nspeed|string|单位：米/秒|√|×\r\nbearing|string|获取方向角信息|√|×\r\nbuildingId|string|获取室内定位建筑物Id|√|×\r\nfloor|string|获取室内定位楼层|√|×\r\ngpsAccuracyStatus|string|获取GPS当前状态，返回值可参考AMapLocation类提供的常量|√|×\r\nlocationType|string|获取定位结果来源|√|×\r\nlocationDetail|string|定位信息描述|√|×\r\n\r\n\r\n#### 6.Ionic4使用方法 <div id=\"Mark\"></div>\r\n```typescript\r\n//ionic 4+ \r\nimport {\r\n  GaoDeLocation,\r\n  PositionOptions,\r\n  LocationModeEnum,\r\n  LocationProtocolEnum,\r\n  DesiredAccuracyEnum,\r\n  PositionRes\r\n} from \"@awesome-cordova-plugins/gao-de-location/ngx\";\r\n...\r\n\r\n@NgModule({\r\n  ...\r\n\r\n  providers: [\r\n    ...\r\n    GaoDeLocation\r\n    ...\r\n  ]\r\n  ...\r\n})\r\nexport class AppModule { }\r\n```\r\n```typescript\r\n\r\n// app.component.ts\r\n// ionic 4+ \r\nimport {\r\n  GaoDeLocation,\r\n  PositionOptions,\r\n  LocationModeEnum,\r\n  LocationProtocolEnum,\r\n  DesiredAccuracyEnum,\r\n  PositionRes\r\n} from \"@awesome-cordova-plugins/gao-de-location/ngx\";\r\n\r\n@Component({ ... })\r\nexport class xxxComponent {\r\n  //注入\r\n  constructor(private gaoDeLocation: GaoDeLocation) {}\r\n  //调用定位\r\n  async getCurrentPosition() {\r\n      const positionOptions: PositionOptions = {\r\n        androidOption: {\r\n          locationMode: LocationModeEnum.Hight_Accuracy,\r\n          gpsFirst: false,\r\n          HttpTimeOut: 30000,\r\n          interval: 2000,\r\n          needAddress: true,\r\n          onceLocation: false,\r\n          onceLocationLatest: false,\r\n          locationProtocol: LocationProtocolEnum.HTTP,\r\n          sensorEnable: false,\r\n          wifiScan: true,\r\n          locationCacheEnable: true\r\n        }, iosOption: {\r\n          desiredAccuracy: DesiredAccuracyEnum.kCLLocationAccuracyBest,\r\n          pausesLocationUpdatesAutomatically: 'YES',\r\n          allowsBackgroundLocationUpdates: 'NO',\r\n          locationTimeout: 10,\r\n          reGeocodeTimeout: 5,\r\n        }\r\n      };\r\n      const positionRes: PositionRes = await this.gaoDeLocation.getCurrentPosition(positionOptions).catch((e: any) => {\r\n        console.log(e);\r\n      }) || null;\r\n      console.log(JSON.stringify(positionRes));\r\n    }\r\n  \r\n    startSerialLocation() {\r\n      const positionOptions: PositionOptions = {\r\n        androidOption: {\r\n          locationMode: LocationModeEnum.Hight_Accuracy,\r\n          gpsFirst: false,\r\n          HttpTimeOut: 30000,\r\n          interval: 2000,\r\n          needAddress: true,\r\n          onceLocation: false,\r\n          onceLocationLatest: false,\r\n          locationProtocol: LocationProtocolEnum.HTTP,\r\n          sensorEnable: false,\r\n          wifiScan: true,\r\n          locationCacheEnable: true\r\n        }, iosOption: {\r\n          desiredAccuracy: DesiredAccuracyEnum.kCLLocationAccuracyBest,\r\n          pausesLocationUpdatesAutomatically: 'YES',\r\n          allowsBackgroundLocationUpdates: 'NO',\r\n          locationTimeout: 10,\r\n          reGeocodeTimeout: 5,\r\n        }\r\n      };\r\n      this.gaoDeLocation.startSerialLocation(positionOptions).subscribe((positionRes: PositionRes) => {\r\n        console.log(JSON.stringify(positionRes));\r\n      });\r\n    }\r\n  \r\n    stopSerialLocation() {\r\n      const positionRes: any = this.gaoDeLocation.stopSerialLocation().catch((e) => {\r\n        console.log(e);\r\n      }) || null;\r\n      console.log(JSON.stringify(positionRes));\r\n    }\r\n}\r\n```\r\n#### 7.联系我:QQ群 390736068\r\n\r\n#### 8.插件调用方式已经传到ionic官网 \r\n[ionic官网快捷链接](https://ionicframework.com/docs/native/gao-de-location)\r\n","readmeFilename":"README.md"}