FireForesight Feature Service Integration Guide

This guide is for third-party consumers that want to load FireForesight feature service data into their own web mapping applications.

Use these endpoints together: /api/services/{apiKey} (service discovery), /api/services/{apiKey}/presentation (service contract), /{apiKey}/FeatureServer/{layerId}/presentation (layer contract), and /{apiKey}/FeatureServer/{layerId}/query?f=geojson (data payload).

The helper JS files under /js/ and the shared popup stylesheet under /css/ are intended for third-party pages that need a faster integration path for popup rendering and preview behavior.

Third-party integrationContract-driven UIChoose a mapping technology below, copy the correct helper file and stylesheet URLs, then wire the feature service data into your own map runtime.

Referencing the JS module

Third-party consumers can import these reusable ES modules directly from the FireForesight Feature Service host:

  • /js/fireforesight-leaflet-viewer.js — full Leaflet-oriented runtime. Use this when you want the service to bootstrap a Leaflet preview page for you.
  • /js/fireforesight-cesium-runtime.js — popup and data-shaping helpers for third-party consumers using their own map framework.
  • /css/fireforesight-popups.css — shared popup stylesheet for the HTML generated by the helper module.
Full public asset URLs

Option A — your page is served by the Feature Service host

<!-- Leaflet full runtime -->
<script type="module">
  import { bootMapPreview } from '/js/fireforesight-leaflet-viewer.js';
  bootMapPreview();
</script>

<!-- Or just the popup helpers (any platform) -->
<script type="module">
  import {
    toCanonicalProperties,
    buildEnhancedPopupHtml,
    createPopupState,
    wirePopupControllers
  } from '/js/fireforesight-cesium-runtime.js';
</script>

Option B — your app bundles its own module file

// /wwwroot/js/my-map.js
import {
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers
} from '/js/fireforesight-cesium-runtime.js';

export async function initMyMap(apiKey, layerId) {
  const contract = await fetch(`/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());
  const data = await fetch(`/${apiKey}/FeatureServer/${layerId}/query?f=geojson`).then(r => r.json());
  // ... render with your chosen platform
}
<!-- Then in the page -->
<script type="module" src="/js/my-map.js"></script>

Option C — third-party site on a different origin

<!-- Your HTML on any origin -->
<link rel="stylesheet" href="https://your-feature-service-host/css/fireforesight-popups.css" />
<script type="module">
  import {
    toCanonicalProperties,
    buildEnhancedPopupHtml,
    createPopupState,
    wirePopupControllers
  } from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';
</script>
If your page is hosted on a different origin, your browser must be allowed to fetch the popup stylesheet, the helper JS file, and the feature service API endpoints cross-origin. See CORS setup for the client-side expectations and server policy details.

What each module exports

// fireforesight-leaflet-viewer.js
export async function bootMapPreview()  // bootstraps a full Leaflet map from URL params

// fireforesight-cesium-runtime.js
export function toCanonicalProperties(rawProperties)
export function buildEnhancedPopupHtml(properties, popupId, contract)
export function createPopupState(properties)
export function wirePopupControllers(popupId, state, doc = document)
export function formatDate(value)

// Cesium convenience helpers
export function attachCesiumPopups(viewer, dataSource, options)  // one-call Cesium integration
export function readEntityProperties(entity)                     // unwraps Cesium Property objects
export function injectPopupStyles(doc, cssUrl)                   // adds the stylesheet to any document
export function getPopupStylesheetUrl()                          // absolute URL of the shared CSS
Use the Leaflet module only for Leaflet preview bootstrapping. All other technologies below consume the runtime helper module together with the service's presentation contract and GeoJSON responses. Include the shared stylesheet if you plan to render the helper-generated popup HTML in your own map implementation.

CORS setup

If your client app is not served from the same origin as the Feature Service, the browser treats helper-file imports, stylesheet loads, and API calls as cross-origin requests. Your client and the Feature Service host must both be set up so those requests are allowed.

  1. The client must import helper JS files, load the popup stylesheet, and call API URLs using the exact deployed Feature Service host name.
  2. The client origin must be allowed by the Feature Service CORS policy if the service is locked down to specific origins.
  3. The client must use the correct scheme and port for both sides, for example https://maps.example.com calling https://feature-service.example.com.

Where CORS is configured

The Feature Service applies CORS globally in the ASP.NET Core pipeline, which covers the JSON endpoints and the static helper assets under /wwwroot/js and /wwwroot/css:

// Program.cs
builder.Services.AddCors(options =>
{
    options.AddPolicy("FeatureServiceCors", policy =>
    {
        policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
    });
});
 
app.UseCors("FeatureServiceCors");

What the client needs to configure

  • Point helper-file imports to the correct full Feature Service URL, not a local relative path from your own app.
  • Point API calls to the same Feature Service host so the presentation contract and GeoJSON data come from the right service instance.
  • If your frontend build tool blocks cross-origin module loading in development, whitelist the Feature Service host in that dev tool as well.
  • If you deploy behind a reverse proxy or gateway, make sure it does not strip Access-Control-Allow-Origin response headers.

What requests must work cross-origin

  • The page origin that imports /js/fireforesight-leaflet-viewer.js or /js/fireforesight-cesium-runtime.js.
  • The page origin that loads /css/fireforesight-popups.css when using the helper-generated popup HTML.
  • The page origin that calls /api/services/{apiKey}, /{apiKey}/FeatureServer/{layerId}/presentation, or /{apiKey}/FeatureServer/{layerId}/query?f=geojson.
  • Each local dev port separately if your frontend and feature service run on different ports.

Third-party consumer example

const featureServiceOrigin = 'https://feature-service.example.com';
 
const contractUrl = `${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`;
const queryUrl = `${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/query?f=geojson`;
const runtimeUrl = `${featureServiceOrigin}/js/fireforesight-cesium-runtime.js`;
const popupCssUrl = `${featureServiceOrigin}/css/fireforesight-popups.css`;
Same-origin pages do not need extra CORS setup. If your HTML, helper JS files, and API requests are all served from the same Feature Service host, the browser will not make cross-origin requests.
The current Feature Service policy allows requests from any origin. If that changes later, third-party consumers will need their exact frontend origin approved on the service host.

Advanced UI implementation model

For third-party consumers, the recommended model is to treat the Feature Service as a remote contract-and-data provider and keep your map framework-specific rendering inside your own application.

  1. Fetch presentation metadata and GeoJSON data.
  2. Normalize properties to canonical keys (incidentId, siteName, patrolSegments, comments).
  3. Build marker style from presentation.renderer.
  4. Build popup shell from presentation.popup.tabs and presentation.popup.fields.
  5. Attach popup controllers (tab switching, image carousel, comments autoscroll, detail formatting).
  6. Keep a mode toggle that switches between default popup and enhanced popup using the same loaded features.

Canonical adapter

function toCanonicalProperties(p) {
  return {
    layerType: p.layerType,
    objectId: p.objectId,
    incidentId: p.incidentId,
    status: p.status,
    siteName: p.siteName ?? p.name,
    siteUri: p.siteUri,
    fireDate: p.fireDate,
    latestImageUrl: p.latestImageUrl,
    latestImageTime: p.latestImageTime,
    comments: Array.isArray(p.comments) ? p.comments : [],
    patrolSegments: Array.isArray(p.patrolSegments) ? p.patrolSegments : [],
    externalLinks: Array.isArray(p.externalLinks) ? p.externalLinks : []
  };
}
Keep feature data immutable in your client app; store popup and carousel UI state separately from the Feature Service response objects.

Leaflet

Leaflet helper JS

Leaflet is the fastest integration path if you want the FireForesight helper to bootstrap the preview experience for a third-party consumer page.

Option A — Use the full Leaflet runtime

<script type="module">
  import { bootMapPreview } from 'https://your-feature-service-host/js/fireforesight-leaflet-viewer.js';
  // Reads key, layer, url, layerId, presentation from the page URL automatically.
  bootMapPreview();
</script>

Option B — Bring your own Leaflet map, use helper functions for popups

<script type="module">
import {
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers
} from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

const featureServiceOrigin = 'https://your-feature-service-host';
const layerContract = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());
const data = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/query?f=geojson`).then(r => r.json());

const popupState = new Map();
const markers = L.layerGroup().addTo(map);

for (const feature of data.features) {
  const p = toCanonicalProperties(feature.properties);
  const [lng, lat] = feature.geometry.coordinates;
  const isIncident = p.layerType === 'incident';
  const popupId = `${feature.id}-${Math.random().toString(36).slice(2, 8)}`;
  popupState.set(popupId, createPopupState(p));

  const marker = L.marker([lat, lng]);
  marker.bindPopup(buildEnhancedPopupHtml(p, popupId, layerContract), {
    className: isIncident ? 'incident-popup' : 'camera-popup',
    minWidth: 620, maxWidth: 620
  });
  marker.on('popupopen', () => wirePopupControllers(popupId, popupState.get(popupId)));
  marker.addTo(markers);
}
</script>
Client-side CORS requirement: your Leaflet page must be able to import the helper module and fetch the presentation/data endpoints from the Feature Service origin.

OpenLayers

OpenLayers helper JS

OpenLayers works well when you want to keep full control of map setup while still reusing FireForesight popup helpers in a third-party app.

OpenLayers uses its own map/layer/style API. Import popup helpers from the runtime module and keep Leaflet out of your bundle.
<script type="module">
import {
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers
} from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

const featureServiceOrigin = 'https://your-feature-service-host';
const contract = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());
const data = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/query?f=geojson`).then(r => r.json());

const features = new ol.format.GeoJSON().readFeatures(data, { featureProjection: 'EPSG:3857' });
const source = new ol.source.Vector({ features });
const vector = new ol.layer.Vector({ source });
map.addLayer(vector);

const popupEl = document.getElementById('popup');
const popup = new ol.Overlay({ element: popupEl, positioning: 'bottom-center', stopEvent: true });
map.addOverlay(popup);

map.on('singleclick', evt => {
  const feature = map.forEachFeatureAtPixel(evt.pixel, f => f);
  if (!feature) return popup.setPosition(undefined);
  const p = toCanonicalProperties(feature.getProperties());
  const popupId = `ol-${Date.now()}`;
  popupEl.innerHTML = buildEnhancedPopupHtml(p, popupId, contract);
  wirePopupControllers(popupId, createPopupState(p));
  popup.setPosition(evt.coordinate);
});
</script>
Client-side CORS requirement: your OpenLayers app must be able to fetch remote ES modules and GeoJSON data from the Feature Service origin.

Mapbox GL JS

Mapbox helper JS

Mapbox GL JS is a good fit when your third-party app already uses vector basemaps and custom interaction layers.

Mapbox GL JS v3+ supports ES modules natively. Import popup helpers from the Feature Service host and keep rendering logic in your own map code.
<script type="module">
import {
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers
} from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

const featureServiceOrigin = 'https://your-feature-service-host';
const contract = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());
const data = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/query?f=geojson`).then(r => r.json());

map.addSource('ff-layer', { type: 'geojson', data });
map.addLayer({
  id: 'ff-points',
  type: 'circle',
  source: 'ff-layer',
  paint: {
    'circle-radius': 7,
    'circle-color': ['case', ['==', ['get', 'layerType'], 'incident'], '#e67e22', '#2b6cb0'],
    'circle-stroke-color': '#fff',
    'circle-stroke-width': 1.5
  }
});

map.on('click', 'ff-points', e => {
  const raw = e.features?.[0]?.properties ?? {};
  // Mapbox serialises nested objects to JSON strings — parse them back
  const parsed = Object.fromEntries(
    Object.entries(raw).map(([k, v]) => {
      try { return [k, JSON.parse(v)]; } catch { return [k, v]; }
    })
  );
  const p = toCanonicalProperties(parsed);
  const popupId = `mb-${Date.now()}`;

  new mapboxgl.Popup({ maxWidth: '640px' })
    .setLngLat(e.lngLat)
    .setHTML(buildEnhancedPopupHtml(p, popupId, contract))
    .addTo(map);

  requestAnimationFrame(() => wirePopupControllers(popupId, createPopupState(p)));
});
</script>
Client-side CORS requirement: the browser must be allowed to import the runtime helper and fetch the remote contract/data endpoints from the Feature Service host.

Cesium

Cesium helper JS

Cesium works well for third-party consumers that need globe or 3D scene rendering while still reusing FireForesight popup formatting helpers.

Cesium renders entity descriptions inside a sandboxed InfoBox iframe, so a stylesheet linked in your page does not reach the popup markup. attachCesiumPopups() handles this for you: it builds every entity description, injects /css/fireforesight-popups.css into the iframe, and wires the tab and carousel controllers when an entity is selected.

Minimal integration

<!-- Styles the Cesium InfoBox chrome in your page.
     The popup markup inside the iframe is styled automatically. -->
<link rel="stylesheet" href="https://your-feature-service-host/css/fireforesight-popups.css" />

<script type="module">
import { attachCesiumPopups } from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

const featureServiceOrigin = 'https://your-feature-service-host';
const contract = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());
const geojson = await fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/query?f=geojson`).then(r => r.json());

const dataSource = await Cesium.GeoJsonDataSource.load(geojson);
viewer.dataSources.add(dataSource);

// One call: descriptions, iframe styling, and popup controllers.
attachCesiumPopups(viewer, dataSource, { contract });

await viewer.zoomTo(dataSource);
</script>

That is the entire integration. attachCesiumPopups returns a handle with a dispose() method if you need to detach the selection listener when tearing down a view.

Options

attachCesiumPopups(viewer, dataSource, {
  contract,   // optional layer presentation contract
  cssUrl,     // optional stylesheet override; defaults to the
              // /css/fireforesight-popups.css next to this module
  timeoutMs   // optional wait for the InfoBox iframe (default 3000)
});
Because the default cssUrl is resolved relative to the module URL, third-party pages loading the module cross-origin automatically get the correct absolute stylesheet URL from the Feature Service host.

Manual wiring (only if you are not using the InfoBox)

<script type="module">
import {
  readEntityProperties,
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers,
  injectPopupStyles
} from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

for (const entity of dataSource.entities.values) {
  const p = toCanonicalProperties(readEntityProperties(entity));
  const popupId = `cz-${entity.id}`;
  entity.description = buildEnhancedPopupHtml(p, popupId, contract);
  // Render into your own container, then:
  //   injectPopupStyles(targetDocument);
  //   wirePopupControllers(popupId, createPopupState(p), targetDocument);
}
</script>

wirePopupControllers(popupId, state, doc = document) takes an optional third doc parameter — the Document that the popup markup from buildEnhancedPopupHtml was actually rendered into. This defaults to the host page's own document, which is correct for the InfoBox iframe case shown above (attachCesiumPopups resolves and passes the iframe's contentDocument for you). If you render the popup markup somewhere else instead — a custom side panel, a portal, a different iframe — pass that container's owner Document as targetDocument so wirePopupControllers queries and wires elements in the right document rather than the top-level page.

Client-side CORS requirement: your Cesium app must be able to import the runtime helper and load the stylesheet from the Feature Service origin, and fetch remote GeoJSON and presentation metadata.

Esri (ArcGIS Maps SDK for JavaScript)

ArcGIS SDK helper JS

The ArcGIS Maps SDK for JavaScript lets a third-party consumer combine FireForesight-hosted feature data with Esri basemaps, widgets, and view lifecycle APIs.

The ArcGIS Maps SDK uses AMD/ESM modules itself. Import the popup helpers from the Feature Service host before the SDK loads, or use a dynamic import() inside your module script.
<!-- Load the ArcGIS SDK normally -->
<link rel="stylesheet" href="https://js.arcgis.com/4.30/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.30/"></script>

<!-- Then load your module script -->
<script type="module">
import {
  toCanonicalProperties,
  buildEnhancedPopupHtml,
  createPopupState,
  wirePopupControllers
} from 'https://your-feature-service-host/js/fireforesight-cesium-runtime.js';

require([
  'esri/Map', 'esri/views/MapView', 'esri/layers/FeatureLayer'
], (EsriMap, MapView, FeatureLayer) => {

  const featureServiceOrigin = 'https://your-feature-service-host';
  const contract = fetch(`${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}/presentation`).then(r => r.json());

  const layer = new FeatureLayer({
    url: `${featureServiceOrigin}/${apiKey}/FeatureServer/${layerId}`,
    outFields: ['*'],
    // drawingInfo and popupInfo from the layer metadata provide sensible defaults.
    // Override popupTemplate to use the enhanced UI:
    popupTemplate: {
      title: (feature) => feature.graphic.attributes.siteName ?? feature.graphic.attributes.SiteName ?? 'Site',
      content: async (feature) => {
        const layerContract = await contract;
        const attrs = feature.graphic.attributes;
        const p = toCanonicalProperties(attrs);
        const popupId = `esri-${Date.now()}`;
        const div = document.createElement('div');
        div.innerHTML = buildEnhancedPopupHtml(p, popupId, layerContract);
        setTimeout(() => wirePopupControllers(popupId, createPopupState(p)), 0);
        return div;
      }
    }
  });

  const map = new EsriMap({ basemap: 'streets-navigation-vector', layers: [layer] });
  new MapView({ container: 'viewDiv', map, zoom: 5, center: [133, -25] });
});
</script>
Client-side CORS requirement: the ArcGIS SDK page must be able to load the helper module and read Feature Service responses from the remote host.

Esri (ArcGIS Online / ArcGIS Pro)

ArcGIS Online and ArcGIS Pro can consume the feature layer URLs directly, without importing the helper JS files. Use this path when you want hosted GIS clients to consume the FireForesight data as a service layer.

Incident layers expose LatestImageUrl and LatestImageTime, plus a Comments field containing the 25 most recent comments, newest first, with each author and UTC timestamp. Additional older comments are available in GeoJSON. Image URLs can expire. For fire pins alongside bearing lines, add the Watching (Basic) point layer (3) and Escalated & Acknowledged (Points) layer (4) alongside their corresponding line layers (2 and 1).

The Sites layer exposes patrol fields by direction, for example LatestImageUrl0 and LatestTimeStamp0 for a segment facing 0 degrees. A negative direction uses Minus in its field suffix, for example LatestImageUrlMinus10. If a site has multiple segments at the same direction, the most recently timestamped segment is used, with the lowest segment ID breaking ties. Configured links remain numbered, for example ExternalLinkName1 and ExternalLinkUrl1. Layer metadata includes directions across all accessible sites regardless of query extent; missing or null values are omitted from individual feature attributes. Refresh layer metadata when available directions change. Image URLs can expire and must be obtained again from the service.

  1. Copy the layer URL from the service browser page.
  2. ArcGIS Online: Add → Add Layer from Web → ArcGIS Server Web Service.
  3. ArcGIS Pro: Catalog → Servers → New ArcGIS Server, then paste service URL.
  4. Renderer and popup defaults are provided via layer metadata; customize as needed in your map.
Helper JS files are not typically used in ArcGIS Online or ArcGIS Pro. Those clients primarily consume the layer and service URLs directly.

Contract-driven popup strategy

Third-party consumers can standardize popup behavior across mapping technologies by treating the Feature Service presentation contract as the source of truth and reusing the helper module exports below.

// These are the actual exported functions from /js/fireforesight-cesium-runtime.js

export function toCanonicalProperties(p) {
  return {
    layerType: p.layerType,
    objectId: p.objectId,
    incidentId: p.incidentId,
    status: p.status,
    siteName: p.siteName ?? p.name,
    siteUri: p.siteUri,
    fireDate: p.fireDate,
    latestImageUrl: p.latestImageUrl,
    latestImageTime: p.latestImageTime,
    comments: Array.isArray(p.comments) ? p.comments : [],
    patrolSegments: Array.isArray(p.patrolSegments) ? p.patrolSegments : [],
    externalLinks: Array.isArray(p.externalLinks) ? p.externalLinks : []
  };
}

export function buildEnhancedPopupHtml(properties, popupId, contract) {
  const tabs = contract.popup?.tabs ?? [];
  const fields = contract.popup?.fields ?? [];
  const detailsRows = fields
    .map(f => `<tr><td>${f.label}</td><td>${properties[f.key] ?? '—'}</td></tr>`)
    .join('');
  return renderPopupShell({ popupId, tabs, detailsRows, properties });
}

export function createPopupState(p) {
  return {
    images: p.patrolSegments?.map(s => ({ url: s.latestImageUrl, direction: s.direction, timestamp: s.latestTimeStamp }))
              ?? (p.latestImageUrl ? [{ url: p.latestImageUrl, timestamp: p.latestImageTime }] : []),
    comments: p.comments ?? [],
    imageIndex: 0,
    activeTab: 'image'
  };
}

export function wirePopupControllers(popupId, state) {
  bindTabEvents(popupId, state);
  bindCarouselEvents(popupId, state);
  renderCurrentImage(popupId, state);
}

export function buildDefaultPopup(properties, isIncident, lat, lng) {
  // Returns a plain text/HTML popup for default mode rendering
  if (isIncident) {
    return `<strong>Incident #${properties.incidentId}</strong><br/>
            ${properties.status} — ${properties.siteName}<br/>
            ${lat.toFixed(6)}, ${lng.toFixed(6)}`;
  }
  return `<strong>${properties.siteName}</strong><br/>${lat.toFixed(6)}, ${lng.toFixed(6)}`;
}

export function formatDate(val) {
  if (!val) return '—';
  const d = new Date(val);
  return isNaN(d) ? String(val) : d.toLocaleString();
}
For production, host this file at /wwwroot/js/fireforesight-cesium-runtime.js and import the exported helpers from Cesium clients using either relative (/js/...) or full cross-domain URLs.