1# 位置服务子系统JS API变更 2 3OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,位置服务子系统的API变更如下: 4 5## 接口变更 6 7| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | 8|---|---|---|---| 9| ohos.geolocation | LocationCommand | command: string; | 新增 | 10| ohos.geolocation | LocationCommand | scenario: LocationRequestScenario; | 新增 | 11| ohos.geolocation | LocationPrivacyType | CORE_LOCATION | 新增 | 12| ohos.geolocation | LocationPrivacyType | STARTUP | 新增 | 13| ohos.geolocation | LocationPrivacyType | OTHERS = 0 | 新增 | 14| ohos.geolocation | GeoLocationErrorCode | LOCATION_REQUEST_TIMEOUT_ERROR | 新增 | 15| ohos.geolocation | GeoLocationErrorCode | LAST_KNOWN_LOCATION_ERROR | 新增 | 16| ohos.geolocation | GeoLocationErrorCode | LOCATION_SWITCH_ERROR | 新增 | 17| ohos.geolocation | GeoLocationErrorCode | LOCATOR_ERROR | 新增 | 18| ohos.geolocation | GeoLocationErrorCode | GEOCODE_ERROR | 新增 | 19| ohos.geolocation | GeoLocationErrorCode | REVERSE_GEOCODE_ERROR | 新增 | 20| ohos.geolocation | GeoLocationErrorCode | INPUT_PARAMS_ERROR = 101 | 新增 | 21| ohos.geolocation | LocationRequestScenario | NO_POWER | 新增 | 22| ohos.geolocation | LocationRequestScenario | DAILY_LIFE_SERVICE | 新增 | 23| ohos.geolocation | LocationRequestScenario | CAR_HAILING | 新增 | 24| ohos.geolocation | LocationRequestScenario | TRAJECTORY_TRACKING | 新增 | 25| ohos.geolocation | LocationRequestScenario | NAVIGATION | 新增 | 26| ohos.geolocation | LocationRequestScenario | UNSET = 0x300 | 新增 | 27| ohos.geolocation | LocationRequestPriority | FIRST_FIX | 新增 | 28| ohos.geolocation | LocationRequestPriority | LOW_POWER | 新增 | 29| ohos.geolocation | LocationRequestPriority | ACCURACY | 新增 | 30| ohos.geolocation | LocationRequestPriority | UNSET = 0x200 | 新增 | 31| ohos.geolocation | Location | additionSize?: number; | 新增 | 32| ohos.geolocation | Location | additions?: Array\<string>; | 新增 | 33| ohos.geolocation | Location | timeSinceBoot: number; | 新增 | 34| ohos.geolocation | Location | direction: number; | 新增 | 35| ohos.geolocation | Location | timeStamp: number; | 新增 | 36| ohos.geolocation | Location | speed: number; | 新增 | 37| ohos.geolocation | Location | accuracy: number; | 新增 | 38| ohos.geolocation | Location | altitude: number; | 新增 | 39| ohos.geolocation | Location | longitude: number; | 新增 | 40| ohos.geolocation | Location | latitude: number; | 新增 | 41| ohos.geolocation | CurrentLocationRequest | timeoutMs?: number; | 新增 | 42| ohos.geolocation | CurrentLocationRequest | maxAccuracy?: number; | 新增 | 43| ohos.geolocation | CurrentLocationRequest | scenario?: LocationRequestScenario; | 新增 | 44| ohos.geolocation | CurrentLocationRequest | priority?: LocationRequestPriority; | 新增 | 45| ohos.geolocation | LocationRequest | maxAccuracy?: number; | 新增 | 46| ohos.geolocation | LocationRequest | distanceInterval?: number; | 新增 | 47| ohos.geolocation | LocationRequest | timeInterval?: number; | 新增 | 48| ohos.geolocation | LocationRequest | scenario?: LocationRequestScenario; | 新增 | 49| ohos.geolocation | LocationRequest | priority?: LocationRequestPriority; | 新增 | 50| ohos.geolocation | GeoAddress | descriptionsSize?: number; | 新增 | 51| ohos.geolocation | GeoAddress | descriptions?: Array\<string>; | 新增 | 52| ohos.geolocation | GeoAddress | addressUrl?: string; | 新增 | 53| ohos.geolocation | GeoAddress | phoneNumber?: string; | 新增 | 54| ohos.geolocation | GeoAddress | postalCode?: string; | 新增 | 55| ohos.geolocation | GeoAddress | premises?: string; | 新增 | 56| ohos.geolocation | GeoAddress | subRoadName?: string; | 新增 | 57| ohos.geolocation | GeoAddress | roadName?: string; | 新增 | 58| ohos.geolocation | GeoAddress | subLocality?: string; | 新增 | 59| ohos.geolocation | GeoAddress | locality?: string; | 新增 | 60| ohos.geolocation | GeoAddress | subAdministrativeArea?: string; | 新增 | 61| ohos.geolocation | GeoAddress | administrativeArea?: string; | 新增 | 62| ohos.geolocation | GeoAddress | countryName?: string; | 新增 | 63| ohos.geolocation | GeoAddress | countryCode?: string; | 新增 | 64| ohos.geolocation | GeoAddress | placeName?: string; | 新增 | 65| ohos.geolocation | GeoAddress | locale?: string; | 新增 | 66| ohos.geolocation | GeoAddress | longitude?: number; | 新增 | 67| ohos.geolocation | GeoAddress | latitude?: number; | 新增 | 68| ohos.geolocation | GeoCodeRequest | maxLongitude?: number; | 新增 | 69| ohos.geolocation | GeoCodeRequest | maxLatitude?: number; | 新增 | 70| ohos.geolocation | GeoCodeRequest | minLongitude?: number; | 新增 | 71| ohos.geolocation | GeoCodeRequest | minLatitude?: number; | 新增 | 72| ohos.geolocation | GeoCodeRequest | maxItems?: number; | 新增 | 73| ohos.geolocation | GeoCodeRequest | description: string; | 新增 | 74| ohos.geolocation | GeoCodeRequest | locale?: string; | 新增 | 75| ohos.geolocation | ReverseGeoCodeRequest | maxItems?: number; | 新增 | 76| ohos.geolocation | ReverseGeoCodeRequest | longitude: number; | 新增 | 77| ohos.geolocation | ReverseGeoCodeRequest | latitude: number; | 新增 | 78| ohos.geolocation | ReverseGeoCodeRequest | locale?: string; | 新增 | 79| ohos.geolocation | Geofence | expiration: number; | 新增 | 80| ohos.geolocation | Geofence | radius: number; | 新增 | 81| ohos.geolocation | Geofence | longitude: number; | 新增 | 82| ohos.geolocation | Geofence | latitude: number; | 新增 | 83| ohos.geolocation | GeofenceRequest | geofence: Geofence; | 新增 | 84| ohos.geolocation | GeofenceRequest | scenario: LocationRequestScenario; | 新增 | 85| ohos.geolocation | GeofenceRequest | priority: LocationRequestPriority; | 新增 | 86| ohos.geolocation | CachedGnssLocationsRequest | wakeUpCacheQueueFull: boolean; | 新增 | 87| ohos.geolocation | CachedGnssLocationsRequest | reportingPeriodSec: number; | 新增 | 88| ohos.geolocation | SatelliteStatusInfo | carrierFrequencies: Array\<number>; | 新增 | 89| ohos.geolocation | SatelliteStatusInfo | azimuths: Array\<number>; | 新增 | 90| ohos.geolocation | SatelliteStatusInfo | altitudes: Array\<number>; | 新增 | 91| ohos.geolocation | SatelliteStatusInfo | carrierToNoiseDensitys: Array\<number>; | 新增 | 92| ohos.geolocation | SatelliteStatusInfo | satelliteIds: Array\<number>; | 新增 | 93| ohos.geolocation | SatelliteStatusInfo | satellitesNumber: number; | 新增 | 94| ohos.geolocation | geolocation | sendCommand(command: LocationCommand, callback: AsyncCallback\<boolean>) : void;<br>sendCommand(command: LocationCommand) : Promise\<boolean>; | 新增 | 95| ohos.geolocation | geolocation | flushCachedGnssLocations(callback: AsyncCallback\<boolean>) : void;<br>flushCachedGnssLocations() : Promise\<boolean>; | 新增 | 96| ohos.geolocation | geolocation | getCachedGnssLocationsSize(callback: AsyncCallback\<number>) : void;<br>getCachedGnssLocationsSize() : Promise\<number>; | 新增 | 97| ohos.geolocation | geolocation | isGeoServiceAvailable(callback: AsyncCallback\<boolean>) : void;<br>isGeoServiceAvailable() : Promise\<boolean>; | 新增 | 98| ohos.geolocation | geolocation | getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback\<Array\<GeoAddress>>) : void;<br>getAddressesFromLocationName(request: GeoCodeRequest) : Promise\<Array\<GeoAddress>>; | 新增 | 99| ohos.geolocation | geolocation | getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback\<Array\<GeoAddress>>) : void;<br>getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise\<Array\<GeoAddress>>; | 新增 | 100| ohos.geolocation | geolocation | requestEnableLocation(callback: AsyncCallback\<boolean>) : void;<br>requestEnableLocation() : Promise\<boolean>; | 新增 | 101| ohos.geolocation | geolocation | isLocationEnabled(callback: AsyncCallback\<boolean>) : void;<br>isLocationEnabled() : Promise\<boolean>; | 新增 | 102| ohos.geolocation | geolocation | getLastLocation(callback: AsyncCallback\<Location>) : void;<br>getLastLocation() : Promise\<Location>; | 新增 | 103| ohos.geolocation | geolocation | getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback\<Location>) : void;<br>getCurrentLocation(callback: AsyncCallback\<Location>) : void;<br>getCurrentLocation(request?: CurrentLocationRequest) : Promise\<Location>; | 新增 | 104| ohos.geolocation | geolocation | off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | 新增 | 105| ohos.geolocation | geolocation | on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | 新增 | 106| ohos.geolocation | geolocation | off(type: 'nmeaMessageChange', callback?: Callback\<string>) : void; | 新增 | 107| ohos.geolocation | geolocation | on(type: 'nmeaMessageChange', callback: Callback\<string>) : void; | 新增 | 108| ohos.geolocation | geolocation | off(type: 'gnssStatusChange', callback?: Callback\<SatelliteStatusInfo>) : void; | 新增 | 109| ohos.geolocation | geolocation | on(type: 'gnssStatusChange', callback: Callback\<SatelliteStatusInfo>) : void; | 新增 | 110| ohos.geolocation | geolocation | off(type: 'cachedGnssLocationsReporting', callback?: Callback\<Array\<Location>>) : void; | 新增 | 111| ohos.geolocation | geolocation | on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback\<Array\<Location>>) : void; | 新增 | 112| ohos.geolocation | geolocation | off(type: 'locationServiceState', callback?: Callback\<boolean>) : void; | 新增 | 113| ohos.geolocation | geolocation | on(type: 'locationServiceState', callback: Callback\<boolean>) : void; | 新增 | 114| ohos.geolocation | geolocation | off(type: 'locationChange', callback?: Callback\<Location>) : void; | 新增 | 115| ohos.geolocation | geolocation | on(type: 'locationChange', request: LocationRequest, callback: Callback\<Location>) : void; | 新增 | 116