RPC Functions
Functions from the SDK can be invoked via rpc.invoke().
Example usage
ts
import { rpc } from '@gi-nx/iframe-sdk';
// Invoke a function
rpc.invoke('setTiles', [sourceId, newTiles]);
// With await
const result = await rpc.invoke('getProjects', []);Map & Navigation
| Function | Description |
|---|---|
| addHtmlPopup | Needs Permission - Add an HTML popup to the map at a specific location. |
| addIframePopup | Needs Permission - LngLatLike and PopupOptions are mapbox gl types |
| clearSDKPopup | Clear/remove the current SDK popup from the map. |
| fitBounds | Fit the map view to contain the specified bounds. |
| flyTo | Animate the map camera to fly to a location. |
| getFeatureState | Get the current state of a Mapbox GL feature. |
| getMapBounds | Get the current map bounds as a GeoJSON FeatureCollection. |
| getMapStyle | Returns the current Mapbox style object. |
| getQueriedFeature | Get the feature currently under the user's mouse cursor (hovered) or last clicked. |
| getSelectedFeatures | Returns the (raw) Giraffe features that are currently selected |
| loadImage | Load an image from a URL to mapbox, the key of which can be further referenced by styles. |
| queryRenderedFeatures | base on https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures |
| removeFeatureState | Needs Permission - Remove previously set state from a Mapbox GL feature. |
| setDrawTool | Set the active drawing tool for map interactions. |
| setFeatureState | Needs Permission - Set arbitrary state on a Mapbox GL feature. |
| setHighlightedFeatures | Set the highlighted features on the map. |
| setSelectedFeatures | Set the selected features by their IDs. |
Layers
| Function | Description |
|---|---|
| activateDrawingLayer | Needs Permission - The active drawing layer is the layer that any new geometry will be added to. |
| activateLensLayer | Needs Permission - Activate the lens for a layer. |
| addLayerToProject | Needs Permission - Add the layer to the project. |
| addTempLayer | Needs Permission - add (or update the style of) a temporary (exists only for the current session/client) layer with a tiled source NB the source cannot be updated once the layer has been added, but the style can. |
| addTempLayerGeoJSON | add a temporary (exists only for the current session/client) layer with GeoJSON data source |
| createDrawingLayer | Needs Permission - Creates a new drawing layer with the given name. |
| createGeoJSONLayer | Needs Permission - Create a new GeoJSON layer from the provided data. |
| createLayer | Needs Permission - Create a layer with full configuration options. |
| deactivateLensLayer | Needs Permission - Close the lens panel and deselect the current lens layer. |
| deleteDrawingLayer | Needs Permission - Deletes a drawing layer and all associated sections. |
| deleteProjectLayer | Needs Permission - Removes a layer from the project. |
| duplicateDrawingLayer | Needs Permission - Duplicates a drawing layer and its associated sections. |
| getLayerContents | Get the layer contents filtered by lens and extent of the provided bounds. |
| getLayerPermission | Get the current user's permission for a layer (layer must be added to the current project). |
| removeTempLayer | Remove a temporary layer from the map. |
| renameDrawingLayer | Needs Permission - Renames an existing drawing layer and updates all associated sections and analytics references. |
| setTiles | Needs Permission - Can be used by an app to override the source of a vector tile layer |
| updateGeoJSONLayerContents | Needs Permission - Utility wrapper this uploads the geojson fc then calls patchLayer if layerName exists, otherwise createLayer then addProjectLayer. |
| updateLayer | Needs Permission - Update a layer's configuration (excluding vector source). |
| updateLayerStyle | Needs Permission - Update the style of a layer. |
| updateTempLayerGeoJSON | update temporary layer data |
Layer Tree
| Function | Description |
|---|---|
| activateViewLayers | Needs Permission - Activate the layers of a view's layerTree and updates the sun position. |
| changeLayerOpacity | Needs Permission - Change the opacity of a layer. |
| changeLayerVisibility | Needs Permission - Change the visibility of a layer. |
| createLayerGroup | Needs Permission - Create an empty group in the layer tree. |
| moveLayerTreeItemIntoGroup | Needs Permission - Move an item into a group. |
| removeLayerGroup | Needs Permission - Remove a group from the layer tree. |
| reorderLayerTreeItem | Needs Permission - Reorder any layer tree item or group. |
Commands
| Function | Description |
|---|---|
| getLensedFeatureMap | Get all features from the currently active lens layer as a Map. |
Blocks
| Function | Description |
|---|---|
| createBlock | Needs Permission - Adds a new block definition to the project |
| deleteBlock | Needs Permission - Removes a block definition from the project. |
| getBlock | Returns the block definition for the given id, or undefined if not found. |
| getBlocks | Returns all block definitions, keyed by id. |
| insertBlock | Needs Permission - Prompts the user to click the map to place an instance of a block. |
| updateBlock | Needs Permission - Updates an existing block definition by merging the provided fields. |
Flows
| Function | Description |
|---|---|
| addFlow | Needs Permission - Adds a flow to the project. |
| deleteFlow | Needs Permission - Removes a flow from the project. |
| getNode | Returns the registered node definition for a given node instance id. |
| getParameterNode | Returns the parameter node associated with a generative transform node type. |
| getParameterNodeDefaultTransform | Returns the default transform object for a given generative transform node type. |
| getProjectFlows | Returns all flows in the current project, keyed by their id. |
| NodeIds | Node ID constants for use with flow functions. |
| updateFlows | Needs Permission - Updates flows by id. |
Content Packs
| Function | Description |
|---|---|
| addContentPackToProject | Needs Permission - Fetches a content pack from url and imports its contents into the current project. |
| fetchContentPacks | Fetches all available content packs from the server. |
| fetchPackContents | Fetches the contents of a specific content pack by its URL or file ID. |
Engine
| Function | Description |
|---|---|
| evaluateFeatures | Evaluates a set of raw sections against the current project state, producing pre-stacked sections keyed by feature ID. |
| stackFeatures | Resolves stacking for pre-stacked sections. |
Scenarios
| Function | Description |
|---|---|
| activateScenario | Activate a scenario, making it the current working scenario. |
| deleteScenario | Needs Permission - Delete a scenario from the project. |
| duplicateScenario | Needs Permission - Duplicate a scenario, creating a copy with all its features. |
| getScenarioFeatures | Get all features belonging to a specific scenario. |
| getScenarios | Retrieves all scenarios for the current project. |
| getVisibleScenarios | Gets the currently visible scenarios. |
| renameScenario | Needs Permission - Renames a scenario. |
| setScenarioVisibility | Sets the visibility of scenarios. |
| soloScenario |
Project
| Function | Description |
|---|---|
| createProjectAttachmentPrompt | Open a file picker dialog for the user to upload a new project attachment. |
| createRawSection | Needs Permission - create a Point, LineString or Polygon geometry that will be saved on Giraffe and that users can edit. |
| createRawSections | Needs Permission - Bulk method of createRawSection |
| deleteRawSection | Needs Permission - Delete a raw section from the project. |
| deleteRawSections | Needs Permission - Delete multiple raw sections from the project. |
| fetchAppCredentials | Fetch credentials for an app. |
| fetchCredentials | Fetch credentials that both the current user and the current app have access to. |
| importRawSections | Needs Permission - Import RawSections into the current project, with options for usages, flows, etc. |
| openProject | Open a project in a new browser tab. |
| selectProjectAttachmentPrompt | Open a dialog for the user to select from existing project attachments. |
| updateProjectApp | Needs Permission - Update a project app configuration. |
| updateRawSection | Needs Permission - Update an existing RawSection. |
| updateRawSections | Needs Permission - Same as updateRawSection but for many features. |
| uploadProjectAttachment | Needs Permission - Upload a file as a project attachment. |
Projects
| Function | Description |
|---|---|
| createProject | Needs Permission - Create a new project with the specified boundary polygon. |
| getProjectBundle | Get the full project bundle including all sections, layers, and configuration. |
| getProjects | Get all projects in the current workspace as a FeatureCollection. |
| patchProperties | Needs Permission - Patch properties on multiple projects. |
| shareWithTeam | Needs Permission - Share projects with a team. |
| syncToProjects | Useful to bulk sync a list of projects/geometries from outside of Giraffe and make corresponding projects in Giraffe. |
| updateProject | Needs Permission - Update a project's geometry or properties. |
Utilities
| Function | Description |
|---|---|
| addMapboxEventListener | add a listener to mapbox events. |
| clearIsolatedFeatures | Clear the isolated features and disable isolate mode if it was enabled. |
| disableBottomBarIframe | Disable and hide the bottom bar iframe. |
| disableIsolateMode | Disables isolate mode. |
| disableMapContentEvents | if called, map content events (e.g. layer added, style updated, etc.) will no longer be dispatched to the SDK app. |
| disableMapHover | if called, mouse coordinates will no longer be dispatched to the SDK app. |
| disableSecondaryAppOverlay | Disable the currently active secondary app overlay. |
| enableBottomBarIframe | Enable a bottom bar iframe for displaying custom content. |
| enableIsolateMode | Enables isolate mode. |
| enableMapContentEvents | if called, map content events (e.g. layer added, style updated, etc.) will be dispatched to the SDK app. By default this is enabled. |
| enableMapHover | if called, mouse coordinates will be dispatched to the SDK app and can be accessed via the state key mapHoverCoords. |
| enableSecondaryAppOverlay | Enable a secondary app overlay (Urban, Analytics, Solar, or Terrain). |
| featureArea | Calculate the area of a GeoJSON feature in square meters. |
| fetchProjectDetails | Fetches details for a given project. |
| fetchUserFiles | Fetches files for the user. |
| fetchVistas | Fetches vistas for a project. |
| fromProjected | Convert local meter coordinates back to geographic coordinates (lng/lat). |
| getAnalyticsResult | Get the analytics result for the current project. |
| getGeoTiff | Export the current 2D map view as a GeoTiff image. |
| getGltf | Export the current 3D scene as a GLTF model. |
| getIsolatedFeatures | Get the currently isolated features. |
| getIsolateMode | Check if isolate mode is enabled. |
| getPng | Export the current map view as a PNG image. |
| getSourceLayerDetails | get layer info to pass to getVectorLayerContents from a layer in the base style eg roads |
| getTeamList | Get the list of teams in the current organization. |
| getTempUrl | Get a temporary URL for accessing files via storage proxy. |
| getTerrainMeshes | Get the terrain meshes as a JSON string. |
| getTiles | get the tile bounding boxes at a given zoom level covering the provided fc, used to start a GIS pipeline eg query or join per tile |
| getUrlParams | Get the current page URL and Giraffe routing context. |
| getUserClaimsJwt | Fetches a signed JWT (RS256) encoding the current user's claims. |
| getUserData | Gets the current user's meta data for a specific app. |
| getVectorLayerContents | Get the contents of a vector tile layer as GeoJSON. |
| navigateTo | Navigate to a different page. |
| readyToClose | Signal that the SDK app is ready to close. |
| removeMapboxEventListener | Remove a previously added Mapbox event listener. |
| setContextMenuItems | Set custom context menu items that appear on right-click. |
| setIsolatedFeatures | Set the features that should be isolated in isolate mode. |
| setTopView | Set the map camera mode to flat 2D or perspective 3D. |
| setUserData | Needs Permission - Sets the current user's meta data for a specific app. |
| toProjected | Convert geographic coordinates (lng/lat) to local meters relative to an origin point. |
| updateUiLayout | Update UI layout settings (sidebar widths, visibility, etc.). |
Select
| Function | Description |
|---|---|
| drawPoint | Prompts the user to click on the map to place a point. |
| getLassoedProjectFeatures | Prompt the user to draw a lasso and return all project features within the selection. |
| getLassoShape | Prompt the user to draw a freehand lasso shape on the map. |
| getSelectableProjectFeatures | Get all project features that are currently selectable on the map. |
| getUserDrawnPolygon | Prompt the user to draw a polygon on the map. |
| pickRawSections | Prompts the user to pick one or more raw sections from the map. |
Usage
| Function | Description |
|---|---|
| createUsage | Needs Permission - Create a new usage definition in the current project. |
| deleteUsage | Needs Permission - Delete a usage definition from the current project. |
| getProjectUsages | Get all usage definitions for the current project. |
| getUsage | Get a single usage definition by name. |
| updateUsage | Needs Permission - Update an existing usage definition. |