> For the complete documentation index, see [llms.txt](https://cde-inc.gitbook.io/cde-cad-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cde-inc.gitbook.io/cde-cad-documentation/fivem-developer-integration/livemap.md). Agents can also search and read this documentation through its [MCP server](https://cde-inc.gitbook.io/cde-cad-documentation/~gitbook/mcp).

# LiveMap & Location Tracking

Push real-time officer locations to the CAD live map. Dispatchers can see all on-duty units on an interactive map with position, heading, and status information.

## Push Location Update

```
POST /api/dispatch/location-update
```

{% hint style="warning" %}
**Update Frequency**

Send updates on a reasonable interval (every several seconds) for **on-duty officers only**. Do not send updates for off-duty players. Excessive updates may trigger rate limiting.
{% endhint %}

### Request Body

```json
{
  "unitId": "license:abc123",
  "unitName": "Officer Smith",
  "x": 195.43,
  "y": -933.12,
  "z": 30.69,
  "heading": 45.5,
  "job": "police",
  "status": "10-8",
  "postal": "342"
}
```

### Response

```json
{ "success": true, "message": "Location updated" }
```

{% hint style="info" %}

* Emits Socket.IO event `unitLocationUpdated` to the dispatch panel.
* Sending `status: "offline"` removes the unit from the live map (e.g. on disconnect).
* If a unit moves close enough to an assigned call, they are automatically marked `10-23` (on-scene).
  {% endhint %}

### Lua Example

```lua
-- server/livemap.lua
RegisterNetEvent('cde-cad:updateLocation')
AddEventHandler('cde-cad:updateLocation', function(data)
    local src = source
    local body = json.encode({
        unitId   = GetPlayerIdentifierByType(src, 'license') or tostring(src),
        unitName = data.unitName or GetPlayerName(src),
        x        = data.x,
        y        = data.y,
        z        = data.z,
        heading  = data.heading,
        job      = data.job or 'police',
        status   = data.status or '10-8',
        postal   = data.postal or ''
    })

    PerformHttpRequest(Config.CadUrl .. '/api/dispatch/location-update',
        function(statusCode)
            if statusCode ~= 200 then
                print('[CDE-CAD] Location update failed: ' .. tostring(statusCode))
            end
        end, 'POST', body, {
            ['Content-Type'] = 'application/json',
            ['x-api-key']    = Config.ApiKey
        }
    )
end)

-- client/livemap.lua
Citizen.CreateThread(function()
    while true do
        local ped = PlayerPedId()
        local coords = GetEntityCoords(ped)
        local heading = GetEntityHeading(ped)

        TriggerServerEvent('cde-cad:updateLocation', {
            x       = coords.x,
            y       = coords.y,
            z       = coords.z,
            heading = heading
        })

        Citizen.Wait(7000) -- Every 7 seconds
    end
end)
```
