簡介
移動終端設備已經深入人們日常生活的方方面面,如查看所在城市的天氣、新聞軼事、出行打車、旅行導航、運動記錄。這些習以為常的活動,都離不開定位用戶終端設備的位置。
當用戶處于這些豐富的使用場景中時,系統的位置定位能力可以提供實時準確的位置數據。對于開發者,設計基于位置體驗的服務,也可以更好的滿足用戶的需求。
當應用在實現基于設備位置的功能時,如:駕車導航,記錄運動軌跡等,可以調用該模塊的API接口,完成位置信息的獲取
基本概念
位置能力用于確定用戶設備在哪里,系統使用位置坐標標示用戶設備的位置,并使用多種定位技術提供位置服務,如GNSS定位、基站定位、WLAN/藍牙定位(基站定位、WLAN/藍牙定位后續統稱“網絡定位技術”)。通過這些定位技術,無論用戶設備在室內或是戶外,都可以準確地確定用戶設備的位置。
- 坐標
系統以1984年世界大地坐標系統為參考,使用經度、緯度數據描述地球上的一個位置。 - GNSS定位
基于全球導航衛星系統,包含:GPS、GLONASS、北斗、Galileo等,通過導航衛星,設備芯片提供的定位算法,來確定設備準確位置。定位過程具體使用哪些定位系統,取決于用戶設備的硬件能力。 - 基站定位
根據設備當前駐網基站和相鄰基站的位置,估算設備當前位置。此定位方式的定位結果精度相對較低,并且需要設備可以訪問蜂窩網絡。 - WLAN、藍牙定位
根據設備可搜索到的周圍WLAN、藍牙設備位置,估算設備當前位置。此定位方式的定位結果精度依賴設備周圍可見的固定WLAN、藍牙設備的分布,密度較高時,精度也相較與基站定位方式更高,同時也需要設備可以訪問網絡。
圖 1子系統架構圖 []()
更多鴻蒙知識更新在gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md
參考前往學習。
約束
- 使用設備的位置能力,需要用戶進行確認并主動開啟位置開關。如果位置開關沒有開啟,系統不會向任何應用提供位置服務。
- 設備位置信息屬于用戶敏感數據,所以即使用戶已經開啟位置開關,應用在獲取設備位置前仍需向用戶申請位置訪問權限。在用戶確認允許后,系統才會向應用提供位置服務。
說明
接口說明
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit LocationKit
*/
import { AsyncCallback, Callback } from './@ohos.base';
import { WantAgent } from './@ohos.wantAgent';
/**
* Provides interfaces for initiating location requests, ending the location service,
* and obtaining the location result cached by the system.
*
* @namespace geolocation
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
declare namespace geolocation {
/**
* Subscribe location changed
*
* @permission ohos.permission.LOCATION
* @param { 'locationChange' } type - Indicates the location service event to be subscribed to.
* @param { LocationRequest } request - Indicates the location request parameters.
* @param { Callback< Location > } callback - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:locationChange
*/
function on(type: 'locationChange', request: LocationRequest, callback: Callback< Location >): void;
/**
* Unsubscribe location changed
*
* @permission ohos.permission.LOCATION
* @param { 'locationChange' } type - Indicates the location service event to be subscribed to.
* @param { Callback< Location > } [callback] - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:locationChange
*/
function off(type: 'locationChange', callback?: Callback< Location >): void;
/**
* Subscribe location switch changed
*
* @permission ohos.permission.LOCATION
* @param { 'locationServiceState' } type - Indicates the location service event to be subscribed to.
* @param { Callback callback - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:locationEnabledChange
*/
function on(type: 'locationServiceState', callback: Callback< boolean >): void;
/**
* Unsubscribe location switch changed
*
* @permission ohos.permission.LOCATION
* @param { 'locationServiceState' } type - Indicates the location service event to be subscribed to.
* @param { Callback [callback] - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:locationEnabledChange
*/
function off(type: 'locationServiceState', callback?: Callback< boolean >): void;
/**
* Subscribe to cache GNSS locations update messages
*
* @permission ohos.permission.LOCATION
* @param { 'cachedGnssLocationsReporting' } type - Indicates the location service event to be subscribed to.
* @param { CachedGnssLocationsRequest } request - Indicates the cached GNSS locations request parameters.
* @param { Callback< Array< Location >> } callback - Indicates the callback for reporting the cached GNSS locations.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:cachedGnssLocationsChange
*/
function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback< Array< Location >>): void;
/**
* Unsubscribe to cache GNSS locations update messages
*
* @permission ohos.permission.LOCATION
* @param { 'cachedGnssLocationsReporting' } type - Indicates the location service event to be subscribed to.
* @param { Callback< Array< Location >> } [callback] - Indicates the callback for reporting the cached gnss locations.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:cachedGnssLocationsChange
*/
function off(type: 'cachedGnssLocationsReporting', callback?: Callback< Array< Location >>): void;
/**
* Subscribe gnss status changed
*
* @permission ohos.permission.LOCATION
* @param { 'gnssStatusChange' } type - Indicates the location service event to be subscribed to.
* @param { Callback< SatelliteStatusInfo > } callback - Indicates the callback for reporting the gnss status change.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:satelliteStatusChange
*/
function on(type: 'gnssStatusChange', callback: Callback< SatelliteStatusInfo >): void;
/**
* Unsubscribe gnss status changed
*
* @permission ohos.permission.LOCATION
* @param { 'gnssStatusChange' } type - Indicates the location service event to be subscribed to.
* @param { Callback< SatelliteStatusInfo > } [callback] - Indicates the callback for reporting the gnss status change.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:satelliteStatusChange
*/
function off(type: 'gnssStatusChange', callback?: Callback< SatelliteStatusInfo >): void;
/**
* Subscribe nmea message changed
*
* @permission ohos.permission.LOCATION
* @param { 'nmeaMessageChange' } type - Indicates the location service event to be subscribed to.
* @param { Callback< string > } callback - Indicates the callback for reporting the nmea message.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:nmeaMessage
*/
function on(type: 'nmeaMessageChange', callback: Callback< string >): void;
/**
* Unsubscribe nmea message changed
*
* @permission ohos.permission.LOCATION
* @param { 'nmeaMessageChange' } type - Indicates the location service event to be subscribed to.
* @param { Callback< string > } [callback] - Indicates the callback for reporting the nmea message.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:nmeaMessage
*/
function off(type: 'nmeaMessageChange', callback?: Callback< string >): void;
/**
* Add a geofence and subscribe geo fence status changed
*
* @permission ohos.permission.LOCATION
* @param { 'fenceStatusChange' } type - Indicates the location service event to be subscribed to.
* @param { GeofenceRequest } request - Indicates the Geo-fence configuration parameters.
* @param { WantAgent } want - Indicates which ability to start when the geofence event is triggered.
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.on#event:gnssFenceStatusChange
*/
function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
/**
* Remove a geofence and unsubscribe geo fence status changed
*
* @permission ohos.permission.LOCATION
* @param { 'fenceStatusChange' } type - Indicates the location service event to be subscribed to.
* @param { GeofenceRequest } request - Indicates the Geo-fence configuration parameters.
* @param { WantAgent } want - Indicates which ability to start when the geofence event is triggered.
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.off#event:gnssFenceStatusChange
*/
function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
/**
* Obtain current location
*
* @permission ohos.permission.LOCATION
* @param { CurrentLocationRequest } request - Indicates the location request parameters.
* @param { AsyncCallback< Location > } callback - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getCurrentLocation
*/
function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback< Location >): void;
/**
* Obtain current location
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback< Location > } callback - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getCurrentLocation
*/
function getCurrentLocation(callback: AsyncCallback< Location >): void;
/**
* Obtain current location
*
* @permission ohos.permission.LOCATION
* @param { CurrentLocationRequest } [request] - Indicates the location request parameters.
* @returns { Promise< Location > } The promise returned by the function.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getCurrentLocation
*/
function getCurrentLocation(request?: CurrentLocationRequest): Promise< Location >;
/**
* Obtain last known location
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback< Location > } callback - Indicates the callback for reporting the location result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getLastLocation
*/
function getLastLocation(callback: AsyncCallback< Location >): void;
/**
* Obtain last known location
*
* @permission ohos.permission.LOCATION
* @returns { Promise< Location > } The promise returned by the function.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getLastLocation
*/
function getLastLocation(): Promise< Location >;
/**
* Obtain current location switch status
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback callback - Indicates the callback for reporting the location switch result.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.isLocationEnabled
*/
function isLocationEnabled(callback: AsyncCallback< boolean >): void;
/**
* Obtain current location switch status
*
* @permission ohos.permission.LOCATION
* @returns { Promise The promise returned by the function.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.isLocationEnabled
*/
function isLocationEnabled(): Promise< boolean >;
/**
* Request enable location
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback callback - Indicates the callback for reporting the location switch status.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
function requestEnableLocation(callback: AsyncCallback< boolean >): void;
/**
* Request enable location
*
* @permission ohos.permission.LOCATION
* @returns { Promise The promise returned by the function.
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
function requestEnableLocation(): Promise< boolean >;
/**
* Obtain address info from location
*
* @permission ohos.permission.LOCATION
* @param { ReverseGeoCodeRequest } request - Indicates the reverse geocode query parameters.
* @param { AsyncCallback< Array< GeoAddress >> } callback - Indicates the callback for reporting the address info.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getAddressesFromLocation
*/
function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback< Array< GeoAddress >>): void;
/**
* Obtain address info from location
*
* @permission ohos.permission.LOCATION
* @param { ReverseGeoCodeRequest } request - Indicates the reverse geocode query parameters.
* @returns { Promise< Array< GeoAddress >> } The promise returned by the function.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getAddressesFromLocation
*/
function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise< Array< GeoAddress >>;
/**
* Obtain latitude and longitude info from location address
*
* @permission ohos.permission.LOCATION
* @param { GeoCodeRequest } request - Indicates the geocode query parameters.
* @param { AsyncCallback< Array< GeoAddress >> } callback - Indicates the callback for reporting the latitude and longitude result.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getAddressesFromLocationName
*/
function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< Array< GeoAddress >>): void;
/**
* Obtain latitude and longitude info from location address
*
* @permission ohos.permission.LOCATION
* @param { GeoCodeRequest } request - Indicates the geocode query parameters.
* @returns { Promise< Array< GeoAddress >> } The promise returned by the function.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getAddressesFromLocationName
*/
function getAddressesFromLocationName(request: GeoCodeRequest): Promise< Array< GeoAddress >>;
/**
* Obtain geocode service status
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback callback - Indicates the callback for reporting the geocode service status.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.isGeocoderAvailable
*/
function isGeoServiceAvailable(callback: AsyncCallback< boolean >): void;
/**
* Obtain geocode service status
*
* @permission ohos.permission.LOCATION
* @returns { Promise The promise returned by the function.
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.isGeocoderAvailable
*/
function isGeoServiceAvailable(): Promise< boolean >;
/**
* Obtain the number of cached GNSS locations reported at a time
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback< number > } callback - Indicates the callback for reporting the cached GNSS locations size.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getCachedGnssLocationsSize
*/
function getCachedGnssLocationsSize(callback: AsyncCallback< number >): void;
/**
* Obtain the number of cached GNSS locations reported at a time
*
* @permission ohos.permission.LOCATION
* @returns { Promise< number > } The promise returned by the function.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.getCachedGnssLocationsSize
*/
function getCachedGnssLocationsSize(): Promise< number >;
/**
* All prepared GNSS locations are returned to the application through the callback function,
* and the bottom-layer buffer is cleared.
*
* @permission ohos.permission.LOCATION
* @param { AsyncCallback callback - Indicates the callback for reporting the result.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.flushCachedGnssLocations
*/
function flushCachedGnssLocations(callback: AsyncCallback< boolean >): void;
/**
* All prepared GNSS locations are returned to the application through the callback function,
* and the bottom-layer buffer is cleared.
*
* @permission ohos.permission.LOCATION
* @returns { Promise The promise returned by the function.
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.flushCachedGnssLocations
*/
function flushCachedGnssLocations(): Promise< boolean >;
/**
* Send extended commands to location subsystem.
*
* @permission ohos.permission.LOCATION
* @param { LocationCommand } command - Indicates the extended Command Message Body.
* @param { AsyncCallback callback - Indicates the callback for reporting the send command result.
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.sendCommand
*/
function sendCommand(command: LocationCommand, callback: AsyncCallback< boolean >): void;
/**
* Send extended commands to location subsystem.
*
* @permission ohos.permission.LOCATION
* @param { LocationCommand } command - Indicates the extended Command Message Body.
* @returns { Promise The promise returned by the function.
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.sendCommand
*/
function sendCommand(command: LocationCommand): Promise< boolean >;
/**
* Satellite status information
*
* @interface SatelliteStatusInfo
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.SatelliteStatusInfo
*/
export interface SatelliteStatusInfo {
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
satellitesNumber: number;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
satelliteIds: Array< number >;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
carrierToNoiseDensitys: Array< number >;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
altitudes: Array< number >;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
azimuths: Array< number >;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
carrierFrequencies: Array< number >;
}
/**
* Parameters for requesting to report cache location information
*
* @interface CachedGnssLocationsRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.CachedGnssLocationsRequest
*/
export interface CachedGnssLocationsRequest {
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
reportingPeriodSec: number;
/**
* @syscap SystemCapability.Location.Location.Gnss
* @since 8
* @deprecated since 9
*/
wakeUpCacheQueueFull: boolean;
}
/**
* Configuring parameters in geo fence requests
*
* @interface GeofenceRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.GeofenceRequest
*/
export interface GeofenceRequest {
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
priority: LocationRequestPriority;
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
scenario: LocationRequestScenario;
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
geofence: Geofence;
}
/**
* Configuring parameters in geo fence requests
*
* @interface Geofence
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.Geofence
*/
export interface Geofence {
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
latitude: number;
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
longitude: number;
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
radius: number;
/**
* @syscap SystemCapability.Location.Location.Geofence
* @since 8
* @deprecated since 9
*/
expiration: number;
}
/**
* Configuring parameters in reverse geocode requests
*
* @interface ReverseGeoCodeRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.ReverseGeoCodeRequest
*/
export interface ReverseGeoCodeRequest {
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
locale?: string;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
latitude: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
longitude: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
maxItems?: number;
}
/**
* Configuring parameters in geocode requests
*
* @interface GeoCodeRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.GeoCodeRequest
*/
export interface GeoCodeRequest {
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
locale?: string;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
description: string;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
maxItems?: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
minLatitude?: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
minLongitude?: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
maxLatitude?: number;
/**
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
maxLongitude?: number;
}
/**
* Data struct describes geographic locations.
*
* @interface GeoAddress
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.GeoAddress
*/
export interface GeoAddress {
/**
* Indicates latitude information.
* A positive value indicates north latitude,
* and a negative value indicates south latitude.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
latitude?: number;
/**
* Indicates longitude information.
* A positive value indicates east longitude ,
* and a negative value indicates west longitude .
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
longitude?: number;
/**
* Indicates language used for the location description.
* zh indicates Chinese, and en indicates English.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
locale?: string;
/**
* Indicates landmark of the location.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
placeName?: string;
/**
* Indicates country code.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
countryCode?: string;
/**
* Indicates country name.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
countryName?: string;
/**
* Indicates administrative region name.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
administrativeArea?: string;
/**
* Indicates sub-administrative region name.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
subAdministrativeArea?: string;
/**
* Indicates locality information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
locality?: string;
/**
* Indicates sub-locality information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
subLocality?: string;
/**
* Indicates road name.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
roadName?: string;
/**
* Indicates auxiliary road information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
subRoadName?: string;
/**
* Indicates house information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
premises?: string;
/**
* Indicates postal code.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
postalCode?: string;
/**
* Indicates phone number.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
phoneNumber?: string;
/**
* Indicates website URL.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
addressUrl?: string;
/**
* Indicates additional information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
descriptions?: Array< string >;
/**
* Indicates the amount of additional descriptive information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Geocoder
* @since 7
* @deprecated since 9
*/
descriptionsSize?: number;
}
/**
* Configuring parameters in location requests
*
* @interface LocationRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.LocationRequest
*/
export interface LocationRequest {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
priority?: LocationRequestPriority;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
scenario?: LocationRequestScenario;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
timeInterval?: number;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
distanceInterval?: number;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
maxAccuracy?: number;
}
/**
* Configuring parameters in current location requests
*
* @interface CurrentLocationRequest
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest
*/
export interface CurrentLocationRequest {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
priority?: LocationRequestPriority;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
scenario?: LocationRequestScenario;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
maxAccuracy?: number;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
timeoutMs?: number;
}
/**
* Provides information about geographic locations
*
* @interface Location
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.Location
*/
export interface Location {
/**
* Indicates latitude information.
* A positive value indicates north latitude,
* and a negative value indicates south latitude.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
latitude: number;
/**
* Indicates Longitude information.
* A positive value indicates east longitude ,
* and a negative value indicates west longitude .
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
longitude: number;
/**
* Indicates location altitude, in meters.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
altitude: number;
/**
* Indicates location accuracy, in meters.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
accuracy: number;
/**
* Indicates speed, in m/s.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
speed: number;
/**
* Indicates location timestamp in the UTC format.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
timeStamp: number;
/**
* Indicates direction information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
direction: number;
/**
* Indicates location timestamp since boot.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
timeSinceBoot: number;
/**
* Indicates additional information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
additions?: Array< string >;
/**
* Indicates the amount of additional descriptive information.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
additionSize?: number;
}
/**
* Enum for location priority
*
* @permission ohos.permission.LOCATION
* @enum { number }
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.LocationRequestPriority
*/
export enum LocationRequestPriority {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
UNSET = 0x200,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
ACCURACY,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
LOW_POWER,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
FIRST_FIX
}
/**
* Enum for location scenario
*
* @permission ohos.permission.LOCATION
* @enum { number }
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.LocationRequestScenario
*/
export enum LocationRequestScenario {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
UNSET = 0x300,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
NAVIGATION,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
TRAJECTORY_TRACKING,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
CAR_HAILING,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
DAILY_LIFE_SERVICE,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
NO_POWER
}
/**
* Enum for error code
*
* @permission ohos.permission.LOCATION
* @enum { number }
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
export enum GeoLocationErrorCode {
/**
* Indicates input parameter error.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
INPUT_PARAMS_ERROR,
/**
* Indicates reverse geocode query failed.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
REVERSE_GEOCODE_ERROR,
/**
* Indicates geocode query failed.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
GEOCODE_ERROR,
/**
* Indicates positioning failed.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
LOCATOR_ERROR,
/**
* Indicates operation failure caused by abnormal location switch.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
LOCATION_SWITCH_ERROR,
/**
* Indicates failed to get the last known location.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
LAST_KNOWN_LOCATION_ERROR,
/**
* Indicates location request timeout.
*
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 7
* @deprecated since 9
*/
LOCATION_REQUEST_TIMEOUT_ERROR
}
/**
* Enum for location privacy type
*
* @permission ohos.permission.LOCATION
* @enum { number }
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.LocationPrivacyType
*/
export enum LocationPrivacyType {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
*/
OTHERS = 0,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
*/
STARTUP,
/**
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
*/
CORE_LOCATION
}
/**
* Location subsystem command structure
*
* @interface LocationCommand
* @permission ohos.permission.LOCATION
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
* @useinstead ohos.geoLocationManager/geoLocationManager.LocationCommand
*/
export interface LocationCommand {
/**
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
*/
scenario: LocationRequestScenario;
/**
* @syscap SystemCapability.Location.Location.Core
* @since 8
* @deprecated since 9
*/
command: string;
}
}
export default geolocation;
審核編輯 黃宇
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。
舉報投訴
-
WLAN
+關注
關注
2文章
652瀏覽量
73016 -
藍牙
+關注
關注
114文章
5767瀏覽量
169819 -
鴻蒙
+關注
關注
57文章
2310瀏覽量
42743 -
OpenHarmony
+關注
關注
25文章
3660瀏覽量
16156
發布評論請先 登錄
相關推薦
鴻蒙原生開發手記:01-元服務開發
使用 RelativeContainer 時發現,按鈕如果處在頂部與元服務右側按鈕同一行的位置區域時,點擊事件不觸發,此時不使用 RelativeContainer 組件,改用其他,如 Column。
參考資料
元
發表于 11-14 17:28
人員定位技術向化工廠的智慧平臺提供精準的位置服務
化工廠的智慧平臺提供精準的位置服務。 人員定位系統功能1、三維展示模塊系統平臺采用三維地圖作為基礎,實現變電站整體的三維場景瀏覽、報警監控、重要數據統計、人員精確定位、歷史軌跡查詢、作業票導入、電子圍欄、作業過
HDC2024?心得分享#主題演講學習-加入鴻蒙生態正當時
與鴻蒙應用的全面加持賦能;鴻蒙生態智能設備超9億;對純凈安全、用戶隱私保護的全面升級與重構;以及如鴻蒙學堂、華為開發者聯盟等完整的鴻蒙
發表于 06-28 10:10
鴻蒙原生應用元服務開發-位置服務申請權限
申請位置權限開發指導
場景概述
應用在使用位置服務系統能力前,需要檢查是否已經獲取用戶授權訪問設備位置信息。如未獲得授權,可以向用戶申請需要的位置
發表于 06-18 15:27
鴻蒙原生應用元服務開發-位置服務開發概述
的位置能力可以提供實時準確的位置數據。對于開發者,設計基于位置體驗的服務,也可以使應用的使用體驗更貼近每個用戶。
當應用在實現基于設備
發表于 06-17 17:47
鴻蒙原生應用元服務開發-位置服務獲取設備信息開發
LocationRequest對象,用于告知系統該向應用提供何種類型的位置服務,以及位置結果上報的頻率。
方式一:
為了面向開發者提供貼近其使用場景的API使用方式,系統定義了幾種常見的位置
發表于 06-14 14:46
鴻蒙原生應用元服務開發-位置服務地理編碼轉化開發
;,errMessage:\" + err.message);
}
參考接口API說明位置服務,應用可以獲得與此坐標匹配的GeoAddress列表,應用可以根據實際使用需求,讀取相應的參數
發表于 06-12 17:22
鴻蒙開發實戰:【藍牙組件】
藍牙服務組件為設備提供接入與使用Bluetooth的相關接口,包括BLE設備gatt相關的操作,以及BLE廣播、掃描等功能。
鴻蒙實戰項目開發:【短信服務】
://gitee.com/openharmony/applications_app_samples.git
git pull origin master
? 最后呢,很多開發朋友不知道需要學習那些鴻蒙技術?
發表于 03-03 21:29
【鴻蒙千帆起】高德地圖攜手HarmonyOS NEXT,開啟智能出行新篇章
和設計提供了寶貴的經驗。通過案例解讀,開發者們可以更加深入地理解鴻蒙提供的一系列調測能力及工具,并學習到如何在實際開發中解決類似的問題。
高德地圖
發表于 02-02 11:09
鴻蒙開發OpenHarmony組件復用案例
)
}
}, item => item)
}
}
}
本文主要是對鴻蒙開發基礎當中的OpenHarmony技術組件復用示例, 更多鴻蒙開發
發表于 01-15 17:37
鴻蒙開發基礎-Web組件之cookie操作
})
...
}
...
本文章主要是對鴻蒙開發當中ArkTS語言的基礎應用實戰,Web組件里的cookie操作。更多的鴻蒙應用開發技
發表于 01-14 21:31
HarmonyOS位置服務開發指南
位置服務開發概述
移動終端設備已經深入人們日常生活的方方面面,如查看所在城市的天氣、新聞軼事、出行打車、旅行導航、運動記錄。這些習以為常的活動,都離不開定位用戶終端設備的位置。
當用戶處于這些豐富
發表于 11-27 16:02
評論