# What Are the Properties of a Data Layer Module in God's Eye View?

> Discover the properties of a data layer module in God's Eye View. Learn about layerName, init, enable, disable, and destroy methods for uniform data source management.

- Repository: [Bilawal Sidhu/gods-eye-view](https://github.com/bilawalsidhu/gods-eye-view)
- Tags: deep-dive
- Published: 2026-09-09

---

**Each data layer module in God's Eye View exposes a standardized contract including `layerName`, `init()`, `enable()`, `disable()`, and `destroy()` methods that allow the central DataLayerManager to register, initialize, and control data sources uniformly.**

The **bilawalsidhu/gods-eye-view** repository implements a modular data architecture where individual layers communicate through a lightweight, predictable interface. Understanding the specific properties of a data layer module in God's Eye View is essential for extending the platform with custom data sources like radio signals, CCTV feeds, or traffic overlays.

## Core Interface Properties

Every data layer module must export an object implementing the following required properties. These properties enable the `DataLayerManager`—located in [`src/data/manager.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/manager.js)—to treat heterogeneous data sources uniformly.

### layerName Identifier

The **`layerName`** property provides a unique string identifier that the manager uses as a registry key. This typically matches the filename or functional domain.

```javascript
// src/data/radio.js
export const layerName = 'radio';

```

In [`src/data/traffic.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/traffic.js), this identifier allows the manager to reference the layer when toggling visibility or checking dependencies.

### init(dataManager, options) Lifecycle Method

The **`init`** function serves as the asynchronous entry point for setup logic. It receives the `DataLayerManager` instance and an options object, handling tasks such as fetching external catalogs, establishing WebSocket connections, or initializing data caches.

```javascript
// src/data/cctv.js
export async function init(dataManager, opts) {
  // Load CCTV tile configurations
  // Establish connection to camera feeds
  // Build internal coordinate cache
}

```

According to the source analysis, this method is invoked during `manager.initAll()` before any layer becomes interactive.

### enable() and disable() State Toggles

Modules must expose **`enable()`** and **`disable()`** methods that control the active state. The manager calls these when users toggle layers via the UI, allowing the module to start or pause data streams without destroying the instance.

```javascript
// src/data/traffic.js
export function enable() {
  // Begin rendering traffic flow vectors
  // Subscribe to real-time updates
}

export function disable() {
  // Hide visual elements
  // Pause data fetching
}

```

### destroy() Cleanup Routine

The **`destroy()`** method handles comprehensive cleanup, removing event listeners, aborting pending fetch requests via `AbortController`, and clearing internal caches to prevent memory leaks. This is critical when the manager tears down or replaces layers.

```javascript
// src/data/traffic.js
export function destroy() {
  // Remove DOM event listeners
  // Abort ongoing fetch requests
  // Clear coordinate cache
}

```

## Optional Configuration Properties

Beyond the required interface, data layer modules may export additional properties that modify manager behavior or provide metadata.

### dependencies Array

The **`dependencies`** array lists other layer names that must initialize before the current module. The `DataLayerManager` respects this ordering during the initialization phase.

```javascript
// src/data/trafficFlowStyle.js
export const dependencies = ['trafficBounds'];

```

This ensures that base boundary data loads before derivative styling layers attempt to reference it.

### config Object

The **`config`** object holds static configuration values such as API endpoints, refresh intervals, or display thresholds. The manager can merge these defaults with runtime options passed during registration.

```javascript
// src/data/trafficBounds.js
export const config = {
  refreshInterval: 30000,
  maxZoom: 18,
  apiEndpoint: '/api/traffic/bounds'
};

```

### subscribe(callback) Event Handling

Some modules expose a **`subscribe`** method that registers consumer callbacks for change events. The manager uses this to forward layer-specific updates to the UI or other dependent modules.

```javascript
// src/data/traffic.js
export function subscribe(callback) {
  // Register callback for data updates
  // Return unsubscribe function
}

```

## DataLayerManager Integration Pattern

The `DataLayerManager`—implemented in [`src/data/manager.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/manager.js)—consumes these properties through a uniform registration pattern. It stores instances in an internal Map keyed by `layerName`, respects `dependencies` during initialization, and routes lifecycle calls to each module.

```javascript
// Conceptual usage based on src/data/manager.js implementation
import { DataLayerManager } from './data/manager.js';
import * as radioLayer from './data/radio.js';
import * as trafficLayer from './data/traffic.js';

const manager = new DataLayerManager();

// Registration phase
manager.register(radioLayer);      // Stores by layerName 'radio'
manager.register(trafficLayer);    // Stores by layerName 'traffic'

// Initialization phase
await manager.initAll();           // Calls init() on each module
                                   // Respects dependencies order

// Runtime control
await manager.setEnabled('radio', true);   // Calls radioLayer.enable()
await manager.setEnabled('traffic', true); // Calls trafficLayer.enable()

```

Because the contract is deliberately minimal, developers can add new data sources—from satellite imagery to IoT sensor networks—without modifying the manager's core logic.

## Summary

- **Required properties:** Every data layer module in God's Eye View must export `layerName`, `init()`, `enable()`, `disable()`, and `destroy()` to integrate with the `DataLayerManager`.
- **Optional properties:** Modules may specify `dependencies` for initialization ordering, `config` for static parameters, and `subscribe()` for event-driven updates.
- **Implementation files:** Reference implementations exist in [`src/data/radio.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/radio.js), [`src/data/traffic.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/traffic.js), and [`src/data/cctv.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/cctv.js), demonstrating the contract in production contexts.
- **Manager coordination:** The `DataLayerManager` in [`src/data/manager.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/manager.js) orchestrates these modules using their standardized interfaces, ensuring consistent lifecycle management across heterogeneous data sources.

## Frequently Asked Questions

### What happens if a data layer module lacks the destroy() method?

The `DataLayerManager` expects `destroy()` to prevent memory leaks and zombie subscriptions. Without it, the manager cannot properly clean up when removing layers, potentially leaving active WebSocket connections or uncleared caches that degrade application performance over time.

### Can a data layer module in God's Eye View depend on multiple other layers?

Yes. The `dependencies` property accepts an array of layer name strings. The `DataLayerManager` initializes layers in topologically sorted order, ensuring all declared dependencies complete their `init()` calls before dependent modules begin their own setup routines.

### How does the DataLayerManager handle async initialization errors?

The `init(dataManager, options)` method is expected to return a Promise. If initialization fails—such as when [`src/data/cctv.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/cctv.js) cannot reach camera APIs—the manager can catch these rejections during `initAll()` and optionally disable the layer or retry based on the error handling strategy implemented in [`src/data/manager.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/manager.js).

### Is the layerName property case-sensitive in God's Eye View?

While the source analysis does not explicitly enforce case constraints, the `DataLayerManager` uses `layerName` as a Map key and for dependency resolution. Best practices demonstrated in [`src/data/radio.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/radio.js) and [`src/data/traffic.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/data/traffic.js) use lowercase, kebab-case strings to ensure consistent referencing across the registry and UI toggle components.