Locate

Use dark colors for code blocksCopy
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

reflected

Attribute changes are reflected on the DOM.

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

reflected

Attribute changes are reflected on the DOM.

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

reflected

Attribute changes are reflected on the DOM.

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

readonlyreflected

Attribute changes are reflected on the DOM.

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
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisPropertyChange

Event
arcgisPropertyChange: { name: "state"; }

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

bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisReady

Event
arcgisReady: undefined
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisSuccess

Event
arcgisSuccess: LocateLocateEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

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