Locate

1
import "@arcgis/map-components/components/arcgis-locate";

Locate component animates the View to the user's current location.

Demo

Properties

PropertyAttributeType
auto-destroy-disabled
boolean
geolocation-options
any
go-to-location-disabled
boolean
(((view: MapView | SceneView, goToParameters: GoToParameters) => void))
icon
string
label
string
{ componentLabel?: string | undefined; title?: string | undefined; currentLocation?: string | undefined; timestamp?: string | undefined; latitude?: string | undefined; longitude?: string | undefined; accuracy?: string | undefined; altitude?: string | undefined; altitudeAccuracy?: string | undefined; heading?: string | undefined; speed?: string | undefined; permissionError?: string | undefined; timeoutError?: string | undefined; positionUnavailable?: string | undefined; cancel?: string | undefined; }
popup-disabled
boolean
position
"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
reference-element
ArcgisLinkChart | ArcgisMap | ArcgisScene | string
scale
number
state
readonly
state
"disabled" | "error" | "feature-unsupported" | "locating" | "ready"

autoDestroyDisabled

Property
autoDestroyDisabled: boolean

If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporary hide it. If this is set, make sure to call the `destroy` method when you are done to prevent memory leaks.

Attribute
auto-destroy-disabled
Default value
false

geolocationOptions

Property
geolocationOptions: any

An object used for setting optional position parameters.

Read more...

Attribute
geolocation-options
Default value
null

goToLocationDisabled

Property
goToLocationDisabled: boolean

Indicates whether to navigate the view to the position and scale of the geolocated result.

Read more...

Attribute
go-to-location-disabled
Default value
false

goToOverride

Property
goToOverride: (((view: MapView | SceneView, goToParameters: GoToParameters) => void))

This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.

Read more...

graphic

Property
graphic: Graphic

The graphic used to show the user's location on the map.

Read more...

icon

Property
icon: string
Attribute
icon
Default value
"gps-off"

label

Property
label: string

The component's default label.

Attribute
label

messageOverrides

Property
messageOverrides: { componentLabel?: string | undefined; title?: string | undefined; currentLocation?: string | undefined; timestamp?: string | undefined; latitude?: string | undefined; longitude?: string | undefined; accuracy?: string | undefined; altitude?: string | undefined; altitudeAccuracy?: string | undefined; heading?: string | undefined; speed?: string | undefined; permissionError?: string | undefined; timeoutError?: string | undefined; positionUnavailable?: string | undefined; cancel?: string | undefined; }

Replace localized message strings with your own strings.

popupDisabled

Property
popupDisabled: boolean

Indicates whether to display the Popup of the result graphic from the locate() method.

Read more...

Attribute
popup-disabled
Default value
false

position

Property
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
Attribute
position
Default value
"top-left"

referenceElement

Property
referenceElement: ArcgisLinkChart | ArcgisMap | ArcgisScene | string
Attribute
reference-element

scale

Property
scale: number

Indicates the scale to set on the view when navigating to the position of the geolocated result, after a location is returned from the track event.

Read more...

Attribute
scale
Default value
null

state

readonly
Property
state: "disabled" | "error" | "feature-unsupported" | "locating" | "ready"

The current state of the component.

Attribute
state
Default value
"disabled"

Methods

MethodSignature
cancelLocate(): Promise<void>
componentOnReady(): Promise<void>
destroy(): Promise<void>
locate(): Promise<GeolocationPosition | null>

cancelLocate

Method
cancelLocate(): Promise<void>

This function provides the ability to interrupt and cancel the process of programmatically obtaining the location of the user's device.

Returns
Promise<void>

componentOnReady

Method
componentOnReady(): Promise<void>

Create a promise that resolves once component is fully loaded.

Returns
Promise<void>

destroy

Method
destroy(): Promise<void>

Permanently destroy the component

Returns
Promise<void>

locate

Method
locate(): Promise<GeolocationPosition | null>
Returns
Promise<GeolocationPosition | null>

Events

EventType
LocateViewModelLocateErrorEvent
{ name: "state"; }
undefined
LocateLocateEvent

arcgisError

Event
arcgisError: LocateViewModelLocateErrorEvent

arcgisPropertyChange

Event
arcgisPropertyChange: { name: "state"; }

Fired when the value of a property is changed. Use this to listen to changes to properties.

arcgisReady

Event
arcgisReady: undefined

arcgisSuccess

Event
arcgisSuccess: LocateLocateEvent

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close