Locator

The Locator object provides methods for displaying and positioning the locator icon. An instance is created via the locator() method on a Unit Map instance.

You can also view a code example on codesandbox.io.

2000

An image of the locator icon.

📘

This icon is used to highlight a single position on the map, most likely that of a user's geolocation, but can have other use cases and is not directly coupled to geo positioning data.

map.on("ready", function() {
	// Create a Locator instance via `map.locator()`, which can only be called once a unit map has loaded.
  
  var locator = map.locator();  
});

Locator.translate([point])

Moves the locator icon to the given position if provided. Otherwise returns the current position value.

Arguments

Argument

Required

Type

Default Value

Description

point

No

Array

undefined

An array representing an x and y coordinate pair of a position in map space.
Example: [1, 5].

Returns

Either an [x, y] coordinates Array of the current position or the object chain.

Locator.show()

Display the locator icon. This method is chainable.

Locator.hide()

Hide the locator icon. This method is chainable.


What’s Next