Software Development Kit (SDK)
Build apps, widgets and workflows for your organization, local context or for the world to use.
Overview
Customizing Giraffe with apps, widgets & workflows makes designing and developing cities more fun, fast and collaborative. Even though Giraffe comes with an array of apps to choose from, they only scratch the surface of what’s possible, and most importantly, what’s most useful for your organization.
To empower the next generation of apps, we've opened up our JavaScript SDK. Allowing web developers to easily connect their own web app to the Giraffe platform. They can leverage Giraffe authentication, hosting, geometries, layers and more to get from prototype to production faster.
SDK reference
Giraffe data and functions are available via API from a number of contexts. They can be accessed by:
Importing the context from
@giraffe/gimapAccessing the API from the context using React's useContext hook
'@giraffe/gimap';
useContext(fastUIState);
API
Simple use case example
In Giraffe, apps can do anything JavaScript can do, but their "home" is the right hand side of the screen. As a straight forward, simple example this live counts how many points you've drawn.
All you have to write is a React component that looks like this:
'react';
import { fastUIState } from
'@giraffe/gimap';
function App() {
const { stackedSections } =
useContext(fastUIState);
const pointCount =
Object.values(stackedSections).filter(f
=> f.geometry.type === "Point").length;
return (
<div className="w-96 p-6">
<p> My First App </p>
<p> I've drawn {pointCount} points.</p>
</div>
);
}
export default App;
Advanced use case example
As a more advanced use case, that still uses less than 150 lines of code, is a travel time catchment calculator (aka isochrone). Most of this code is copied verbatim from this Mapbox example.
Get started
Start developing by downloading the latest SDK. This includes examples and the required Giraffe libraries. Please read the included README file.