1e41f4b71Sopenharmony_ci# LocationButton 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **\<LocationButton>** security component allows you to obtain temporary precise location permission from the user by their touching the button, eliminating the need for a permission request dialog box. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Child Components 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciNot supported 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## APIs 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci### LocationButton 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciLocationButton() 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciCreates a Location button with an icon, text, and background. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciYou may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci### LocationButton 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ciLocationButton(option:LocationButtonOptions) 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ciCreates a Location button that contains the specified elements. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciYou may want to learn the [restrictions on security component styles](../../../security/AccessToken/security-component-overview.md#constraints) to avoid authorization failures caused by incompliant styles. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Parameters** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 42e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 43e41f4b71Sopenharmony_ci| option | [LocationButtonOptions](#locationbuttonoptions) | No| Creates a Location button that contains the specified elements.| 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## LocationButtonOptions 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 52e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 53e41f4b71Sopenharmony_ci| icon | [LocationIconStyle](#locationiconstyle) | No| Icon style of the Location button.<br>If this parameter is not specified, no icon is contained. Either **icon** or **text**, or both, must be set.| 54e41f4b71Sopenharmony_ci| text | [LocationDescription](#locationdescription) | No| Text on the Location button.<br>If this parameter is not specified, no text is contained. Either **icon** or **text**, or both, must be set.| 55e41f4b71Sopenharmony_ci| buttonType | [ButtonType](ts-basic-components-button.md#buttontype) | No| Background type of the Location button.<br>If this parameter is not specified, the system uses a capsule-type button. | 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci## LocationIconStyle 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci| Name| Value| Description| 64e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 65e41f4b71Sopenharmony_ci| FULL_FILLED | 0 | Filled style icon.| 66e41f4b71Sopenharmony_ci| LINES | 1 | Line style icon.| 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci## LocationDescription 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci| Name| Value| Description| 75e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 76e41f4b71Sopenharmony_ci| CURRENT_LOCATION | 0 | The text on the Location button is **Current location**.| 77e41f4b71Sopenharmony_ci| ADD_LOCATION | 1 | The text on the Location button is **Add location**.| 78e41f4b71Sopenharmony_ci| SELECT_LOCATION | 2 | The text on the Location button is **Select location**.| 79e41f4b71Sopenharmony_ci| SHARE_LOCATION | 3 | The text on the Location button is **Share location**.| 80e41f4b71Sopenharmony_ci| SEND_LOCATION | 4 | The text on the Location button is **Send location**.| 81e41f4b71Sopenharmony_ci| LOCATING | 5 | The text on the Location button is **Locate**.| 82e41f4b71Sopenharmony_ci| LOCATION | 6 | The text on the Location button is **Location**.| 83e41f4b71Sopenharmony_ci| SEND_CURRENT_LOCATION | 7 | The text on the Location button is **Send current location**.| 84e41f4b71Sopenharmony_ci| RELOCATION | 8 | The text on the Location button is **Relocate**.| 85e41f4b71Sopenharmony_ci| PUNCH_IN | 9 | The text on the Location button is **Punch in**.| 86e41f4b71Sopenharmony_ci| CURRENT_POSITION | 10 | The text on the Location button is **Current position**.| 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci## LocationButtonOnClickResult 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci| Name| Value| Description| 95e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 96e41f4b71Sopenharmony_ci| SUCCESS | 0 | The Location button is touched successfully.| 97e41f4b71Sopenharmony_ci| TEMPORARY_AUTHORIZATION_FAILED | 1 | Temporary authorization fails after the Location button is touched.| 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci## Attributes 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ciThis component can only inherit the [universal attributes of security components](ts-securitycomponent-attributes.md#attributes) 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci## Events 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ciOnly the following events are supported. 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci### onClick 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_cionClick(event: (event: ClickEvent, result: LocationButtonOnClickResult) => void) 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ciCalled when a click event occurs. 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci**Parameters** 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 120e41f4b71Sopenharmony_ci|------------|------|-------|---------| 121e41f4b71Sopenharmony_ci| event | [ClickEvent](ts-universal-events-click.md#clickevent) |Yes|See **ClickEvent**.| 122e41f4b71Sopenharmony_ci| result | [LocationButtonOnClickResult](#locationbuttononclickresult)| Yes| Authorization result.| 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci## Example 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci```ts 127e41f4b71Sopenharmony_ci// xxx.ets 128e41f4b71Sopenharmony_ci@Entry 129e41f4b71Sopenharmony_ci@Component 130e41f4b71Sopenharmony_cistruct Index { 131e41f4b71Sopenharmony_ci build() { 132e41f4b71Sopenharmony_ci Row() { 133e41f4b71Sopenharmony_ci Column({space:10}) { 134e41f4b71Sopenharmony_ci // Create a default Location button with an icon, text, and background. 135e41f4b71Sopenharmony_ci LocationButton().onClick((event: ClickEvent, result: LocationButtonOnClickResult)=>{ 136e41f4b71Sopenharmony_ci console.info("result " + result) 137e41f4b71Sopenharmony_ci }) 138e41f4b71Sopenharmony_ci // Whether an element is contained depends on whether the parameter corresponding to the element is specified. If buttonType is not passed in, the button uses the ButtonType.Capsule settings. 139e41f4b71Sopenharmony_ci LocationButton({icon:LocationIconStyle.LINES}) 140e41f4b71Sopenharmony_ci // Create a button with only an icon and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF. 141e41f4b71Sopenharmony_ci LocationButton({icon:LocationIconStyle.LINES, buttonType:ButtonType.Capsule}) 142e41f4b71Sopenharmony_ci .backgroundColor(0x10007dff) 143e41f4b71Sopenharmony_ci // Create a button with an icon, text, and background. If the alpha value of the most significant eight bits of the background color is less than 0x1A, the system forcibly adjusts the alpha value to 0xFF. 144e41f4b71Sopenharmony_ci LocationButton({icon:LocationIconStyle.LINES, text:LocationDescription.CURRENT_LOCATION, buttonType:ButtonType.Capsule}) 145e41f4b71Sopenharmony_ci }.width('100%') 146e41f4b71Sopenharmony_ci }.height('100%') 147e41f4b71Sopenharmony_ci } 148e41f4b71Sopenharmony_ci} 149e41f4b71Sopenharmony_ci``` 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci 152