MapPrism2D API
This reference describes the public runtime API exposed by the MapPrism2D class.
Constructor
ts
new MapPrism2D(container: HTMLElement, config: MapPRISMConfig)Parameters
| Parameter | Type | Description |
|---|---|---|
container | HTMLElement | DOM element that will host the map |
config | MapPRISMConfig | Full MapPRISM system config object containing map2d |
Behavior
- Constructor call is synchronous.
- Internal map setup is asynchronous.
- Subscribe to
readybefore depending on rendered state.
ts
const map = new MapPrism2D(container, config);
map.on("ready", () => {
// Safe to run map-dependent behavior here
});Layer management
ts
map.addLayer(layer: Layer): void
map.removeLayer(id: string): void
map.updateLayer(id: string, patch: Partial<Layer>): void
map.getLayers(): Layer[]Typical use
ts
map.addLayer({
id: "backscatter",
name: "Backscatter",
type: "raster",
url: "https://example.com/{z}/{x}/{y}.png",
visible: true,
opacity: 1,
order: 2,
scheme: "tms",
});
map.updateLayer("backscatter", { opacity: 0.6 });Basemap control
ts
map.setBasemap(type: "basemap" | "satellite" | "hybrid" | "basemap-2.5d" | "hybrid-2.5d"): voidUse this to switch context between analytical and imagery views without recreating the map.
| Value | Description |
|---|---|
"basemap" | CartoDB Positron analytical map |
"satellite" | Google satellite imagery, labels on top |
"hybrid" | Satellite imagery with road network (lines + labels) on top |
"basemap-2.5d" | CartoDB Positron with extruded buildings |
"hybrid-2.5d" | Satellite imagery + road network + extruded buildings |
View handoff API
ts
map.getView(): {
center: [number, number];
bearing: number;
zoom: number;
}
map.setView(
view: Partial<{ center: [number, number]; bearing: number; zoom: number }>,
opts?: { animate: boolean }
): voidAll public coordinates are WGS84 ([lng, lat]), regardless of how your 3D system stores camera coordinates internally.
Events API
ts
map.on(event: MapEvent, callback: Function): void
map.off(event: MapEvent, callback: Function): voidSee Events for each event payload and recommended usage patterns.
Lifecycle methods
ts
map.resize(): void
map.destroy(): void- Call
resize()when the container dimensions change (tab switch, split pane resize, panel expand/collapse). - Call
destroy()when unmounting the map to release listeners and DOM resources.
Tools API
Measurement tools are exposed under map.tools.measurement.
ts
map.tools.measurement.startLine(): void
map.tools.measurement.startArea(): void
map.tools.measurement.startDelete(): void
map.tools.measurement.stopDelete(): void
map.tools.measurement.stop(): void
map.tools.measurement.cancel(): void
map.tools.measurement.deleteById(id: string): void
map.tools.measurement.clear(): void
map.tools.measurement.getDrawings(): MeasurementDrawing[]If your application has a custom toolbar, you can disable built-in measurement controls in config and drive these methods directly.