---
updatedAt: 2026-06-02T16:06:11.000Z
agentTools:
  projectIndex: https://developers.unitmap.com/llms.txt
---

# Geo

The Geo instance provides methods for translating between geo space and map space. An instance is created via the [`UnitMap.geo()`](https://developers.unitmap.com/docs/js-api-unitmap#unitmapgeo) method.

<Embed title="Geo Example" typeOfEmbed="iframe" url="https://codesandbox.io/embed/georeference-5nlwj?view=preview&module=%2Findex.html&hidenavigation=1" height="500px" width="100%" />

```javascript Usage Example
map.on("ready", function() {
  // Create a Geo instance via `map.geo()`, which can only be called once the map has loaded.

  var geo = map.geo();
});
```

> 🚧 Georeference Support
>
> This feature is only supported for georeferenced unit maps. When implementing, you can feature detect using the `isSupported()` method described in the documentation below.

## Geo.isSupported()

If the loaded unit map is georeferenced, this method returns `true`, otherwise `false`.

```javascript Usage Example
if (geo.isSupported()) {
  console.log("The unit map is georeferenced.");
} else {
  console.log("The unit map is not georeferenced.");
}
```

#### Returns

A Boolean.

## Geo.inBounds(latLng)

Determine if the given position is within the viewport (screen space).

```javascript Usage Example
if (geo.inBounds([32.9348319, -96.8533228])) {
  console.log("The position is within the viewport.");
} else {
  console.log("The position is outside the viewport.");
}
```

#### Arguments

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Argument
      </th>

      <th>
        Required
      </th>

      <th>
        Type
      </th>

      <th>
        Default Value
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        latLng
      </td>

      <td>
        Yes
      </td>

      <td>
        Array
      </td>

      <td>
        undefined
      </td>

      <td>
        An array representing a latitude and longitude coordinate pair of a position in geo space.\
        Example: `[32.9348319, -96.8533228]`.
      </td>
    </tr>
  </tbody>
</Table>

#### Returns

A Boolean.

## Geo.inMapBounds(latLng)

Determine if the given position is within the unit map's bounds.

```javascript Usage Example
if (geo.inMapBounds([32.9348319, -96.8533228])) {
  console.log("The position is within the unit map's bounds.");
} else {
  console.log("The position is outside the unit map's bounds.");
}
```

#### Arguments

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Argument
      </th>

      <th>
        Required
      </th>

      <th>
        Type
      </th>

      <th>
        Default Value
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        latLng
      </td>

      <td>
        Yes
      </td>

      <td>
        Array
      </td>

      <td>
        undefined
      </td>

      <td>
        An array representing a latitude and longitude coordinate pair of a position in geo space.\
        Example: `[32.9348319, -96.8533228]`.
      </td>
    </tr>
  </tbody>
</Table>

#### Returns

A Boolean.

## Geo.toLocal(latLng)

Translate the given position from geo space into map space.

```javascript Usage Example
// Translate the map to a `[latitude, longitude]` coordinate.

map.translate(geo.toLocal([32.9348319, -96.8533228]));
```

#### Arguments

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Argument
      </th>

      <th>
        Required
      </th>

      <th>
        Type
      </th>

      <th>
        Default Value
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        latLng
      </td>

      <td>
        Yes
      </td>

      <td>
        Array
      </td>

      <td>
        undefined
      </td>

      <td>
        An array representing a latitude and longitude coordinate pair of a position in geo space.\
        Example: `[32.9348319, -96.8533228]`.
      </td>
    </tr>
  </tbody>
</Table>

#### Returns

An `[x, y]` coordinates Array or `null` if the loaded unit map is not georeferenced.

## Geo.fromLocal(point)

Translate the given position from map space into geo space.

```javascript Usage Example
var mapElement = document.getElementById("map");

// Output the latitude, longitude of the current mouse position to the console.

mapElement.addEventListener("mousemove", function(event) {
  var latLng = geo.fromLocal(map.toLocal([event.pageX, event.pageY]))

  console.log(latLng);
});
```

#### Arguments

<Table align={["left","left","left","left","left"]}>
  <thead>
    <tr>
      <th>
        Argument
      </th>

      <th>
        Required
      </th>

      <th>
        Type
      </th>

      <th>
        Default Value
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        point
      </td>

      <td>
        Yes
      </td>

      <td>
        Array
      </td>

      <td>
        undefined
      </td>

      <td>
        An array representing an x and y coordinate pair of a position in map space.\
        Example: `[1, 5]`.
      </td>
    </tr>
  </tbody>
</Table>

#### Returns

An `[latitude, longitude]` coordinates Array or `null` if the loaded unit map is not georeferenced.