PowerApps 中的加速度、应用、指南针、连接和位置信号Acceleration, App, Compass, Connection, and Location signals in PowerApps

返回关于应用环境的信息,例如用户的全球所在位置,以及所显示的是哪个屏幕。Returns information about the app's environment, such as where the user is located in the world and which screen is displayed.

说明和语法Description and syntax

所有信号都将返回信息的记录All signals return a record of information. 可以使用此信息并将其存储为记录,也可提取单个属性,其方式是使用“.”You can use and store this information as a record, or you can extract individual properties by using the . 运算符operator.

加速度Acceleration

加速度信号以相对于设备屏幕的三维方式返回设备的加速度。The Acceleration signal returns the device's acceleration in three dimensions relative to the device's screen. 加速度的测量单位为 g(9.81 m/s2 或 32.2 ft/s2)(地球由于重力而在其表面对物体产生的加速度)。Acceleration is measured in g units of 9.81 m/second2 or 32.2 ft/second2 (the acceleration that the Earth imparts to objects at its surface due to gravity).

信号属性Signal Property 说明Description
Acceleration.XAcceleration.X 右侧和左侧。Right and left. 右侧为正数。Right is a positive number.
Acceleration.YAcceleration.Y 前方和后方。Forward and back. 前方为正数。Forward is a positive number.
Acceleration.ZAcceleration.Z 上方和下方。Up and down. 上方为正数。Up is a positive number.

应用App

应用信号返回正在运行的应用的相关信息。The App signal returns information about the running app.

信号属性Signal Property 说明Description
App.ActiveScreenApp.ActiveScreen 所显示的屏幕。Screen that's displayed. 返回一个屏幕对象,可用于引用屏幕属性,或与其他屏幕进行比较,以判断显示的是哪个屏幕。Returns a screen object, which you can use to reference properties of the screen or compare to another screen to determine which screen is displayed. 使用 BackNavigate 函数可以更改显示的屏幕。By using the Back or Navigate function, you can change the displayed screen.

指南针Compass

指南针信号返回屏幕顶部的指南针标题。The Compass signal returns the compass heading of the top of the screen. 该标题以磁北方为基础。The heading is based on magnetic north.

信号属性Signal Property 说明Description
Compass.HeadingCompass.Heading 标题以度为单位。Heading in degrees. 返回一个介于 0 到 360 之间的数值,0 表示北方。Returns a number 0 to 360, and 0 is north.

连接Connection

连接信号返回网络连接的相关信息。The Connection signal returns the information about the network connection. 如果连接按流量计费,建议限制通过网络发送或接受数据的量。When on a metered connection, you may want to limit how much data you send or receive over the network.

信号属性Signal Property 说明Description
Connection.ConnectedConnection.Connected 返回一个布尔值 truefalse,指示设备是否已连接到网络。Returns a Boolean true or false value that indicates whether the device is connected to a network.
Connection.MeteredConnection.Metered 返回一个布尔值 truefalse,指示连接是否按流量计费。Returns a Boolean true or false value that indicates whether the connection is metered.

位置Location

位置信号基于全球定位系统 (GPS) 和其他设备信息(如手机基站通信和 IP 地址)返回设备的位置。The Location signal returns the location of the device based on the Global Positioning System (GPS) and other device information, such as cell-tower communications and IP address.

用户首次访问位置信息时,设备可能会提示该用户,以允许访问此信息。When a user accesses the location information for the first time, the device may prompt that user to allow access to this information.

随着位置在不断改变,位置上的依赖项将不断被重新计算,这将消耗设备电池的电量。As the location changes, dependencies on the location will continuously recalculate, which will consume power from the device's battery. 要维护电池寿命,可使用 EnableDisable 函数打开或关闭位置更新。To conserve battery life, you can use the Enable and Disable functions to turn location updates on and off. 如果显示的屏幕不依赖于位置信息,位置将自动关闭。Location is automatically turned off if the displayed screen doesn't depend on location information.

信号属性Signal Property 说明Description
Location.AltitudeLocation.Altitude 返回一个指示海拔高度的数值(用英尺表示)。Returns a number that indicates the altitude, measured in feet, above sea level.
Location.LatitudeLocation.Latitude 返回一个介于 - 90 至 90 之间的数值,该值指示从赤道起以度数表示的纬度。Returns a number, from -90 to 90, that indicates the latitude, as measured in degrees from the equator. 正数表示赤道以北的位置。A positive number indicates a location that's north of the equator.
Location.LongitudeLocation.Longitude 返回一个介于 0 至 180 之间的数值,该值指示从英国格林威治以西起用度数表示的经度。Returns a number, from 0 to 180, that indicates the longitude, as measured in degrees west from Greenwich, England.

示例Examples

在华盛顿的西雅图塞菲科球场中,一位棒球投手从投球区向本垒的捕手投掷了一部手机。From the pitcher's mound at Safeco Field in Seattle, Washington, a baseball pitcher throws a phone to a catcher at home plate. 该手机相对于地面是平行移动的,手机的屏幕顶端指向捕手,且投手在投掷过程中未使手机发生旋转。The phone is lying flat with respect to the ground, the top of the screen is pointed at the catcher, and the pitcher adds no spin. 在该位置,这部手机连接的是按流量计费的移动网络服务,没有 WiFi。At this location, the phone has cellular network service that's metered but no WiFi. 将显示 PlayBall 屏幕。The PlayBall screen is displayed.

公式Formula 说明Description 结果Result
Location.LatitudeLocation.Latitude 返回当前位置的纬度。Returns the latitude of the current location. 塞菲科球场在地图上的坐标定位是 47.591 N,122.333 W。Safeco Field is located at map coordinates 47.591 N, 122.333 W. 47.59147.591

纬度将随球在投手和捕手之间的移动而不断更改。The latitude will change continuously as the ball moves between the pitcher and the catcher.
Location.LongitudeLocation.Longitude 返回当前位置的经度。Returns the longitude of the current location. 122.333122.333

经度将随球在投手和捕手之间的移动而不断更改。The longitude will change continuously as the ball moves between the pitcher and the catcher.
位置Location 返回当前位置的经度和纬度作为记录。Returns the latitude and longitude of the current location, as a record. { 纬度: 47.591,经度: 122.333 }{ Latitude: 47.591, Longitude: 122.333 }
Compass.HeadingCompass.Heading 返回屏幕顶部的指南针标题。Returns the compass heading of the top of the screen. 在塞菲科球场,本垒大致位于投手区的西南侧。At Safeco Field, home plate is roughly southwest from the pitcher's mound. 230.25230.25
Acceleration.XAcceleration.X 返回并排设备的加速度。Returns the acceleration of the device side to side. 由于投手直接向前相对屏幕的顶端投掷手机,因此设备不会并排加速。The pitcher is throwing the phone straight ahead with respect to the screen's top, so the device isn't accelerating side to side. 00
Acceleration.YAcceleration.Y 返回设备从前到后的加速度。Returns the acceleration of the device front to back. 在投掷设备之初,投手为设备提供了一个较大的加速度,在半秒中内达到从 0 增至 90 英里/小时(132 英尺/秒)。The pitcher initially gives the device a large acceleration when throwing the device, going from 0 to 90 miles per hour (132 feet per second) in half a second. 设备在空中运动时,忽略空气阻力,设备不会进一步加速。After the device is in the air, ignoring air friction, the device doesn't accelerate further. 捕手接住设备时,设备将减速至停止。The device decelerates when the catcher catches it, bringing it to a stop. 8.2,投手投掷设备时。8.2, while the pitcher throws the device.

0,设备在空中时。0, while the device is in the air.

-8.2,捕手接住设备时。-8.2, as the catcher catches the device.
Acceleration.ZAcceleration.Z 返回设备从上到下的加速度。Returns the acceleration of the device top to bottom. 设备在空中运动时会受重力影响。While in the air, the device experiences the effects of gravity. 0,投手投掷设备前。0, before the pitcher throws the device.

1,设备在空中运动时。1, while the device is in the air.

0,捕手接住设备后。0, after the catcher catches the device.
加速度Acceleration 将加速度作为记录返回。Returns the acceleration as a record. { X: 0, Y: 264, Z: 0 },投手投掷设备时。{ X: 0, Y: 264, Z: 0 } as the pitcher throws the device.
Connection.ConnectedConnection.Connected 返回一个布尔值,它指示设备是否已连接到网络Returns a Boolean value that indicates whether the device is connected to a network truetrue
Connection.MeteredConnection.Metered 返回一个布尔值,它指示连接是否按流量计费Returns a Boolean value that indicates whether the connection is metered truetrue
App.ActiveScreen = PlayBallApp.ActiveScreen = PlayBall 返回一个布尔值,它指示是否显示了 PlayBallReturns a Boolean value that indicates whether PlayBall is displayed. truetrue
App.ActiveScreen.FillApp.ActiveScreen.Fill 返回所显示的屏幕的背景色。Returns the background color for the displayed screen. Color.GreenColor.Green