Skip to content

Commit 31aa742

Browse files
authored
Merge pull request #102 from smplrspace/next
v2.39.0
2 parents 7b7720e + 6e3881c commit 31aa742

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

docs/api-reference/map/data-layers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface PolygonMapDataLayerDefinition {
2323
id: string
2424
data: [{
2525
id: string
26+
spaceId: string
2627
coordinates: [{
2728
levelIndex: number
2829
x: number
@@ -45,7 +46,7 @@ map.updatePolygonDataLayer(definitionUpdates: Partial<PolygonMapDataLayerDefinit
4546
```
4647

4748
- `id` is a unique identifier for this layer which is used for updates.
48-
- `data` is an array of objects (refered to as data elements) to be rendered. Each element **must** have an `id` (unique identifier within the data array) and a `coordinates` array.
49+
- `data` is an array of objects (refered to as data elements) to be rendered. Each element **must** have an `id` (unique identifier within the data array), a `spaceId` to transform the local coordinates to global coordinates, and a (local) `coordinates` array.
4950
- `coordinates` in its simple form is an array of points in the 2D horizontal space, it can also be an array of "rings" where the first ring is the external perimeter of the polygon, and the others are "holes" cut into the external perimeter.
5051
- `customData` - _optional_ - elements can also contain any additional custom data used for rendering options.
5152
- `baseHeight` - _optional_ - defines the elevation from the ground at the base of the polygon in meters. It can be defined as a number for all elements or per element with a function that takes each element as argument and returns the base height for that element. _Default value: 0m._

docs/api-reference/space/data-layers.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,28 +163,39 @@ space.addIconDataLayer({
163163
}]
164164
icon: IconSource | (dataElement: object) => IconSource // see IconSource below
165165
width?: number | (dataElement: object) => number
166+
colorOverlay?: string | ((dataElement: object) => string)
166167
onDrag?: ({ data: object }) => void
167168
onDrop?: ({ data: object; position: object }) => void
168169
disableElevationCorrection?: boolean
169170
}) => DataLayerController
170171

171-
interface IconSource {
172-
url: string
173-
width: number
174-
height: number
175-
}
172+
type IconSource =
173+
| {
174+
url: string
175+
width: number
176+
height: number
177+
}
178+
| {
179+
blob: Blob;
180+
blobIdOrHash: string
181+
width: number
182+
height: number
183+
}
176184
```
177185
178186
- `id` is a unique identifier for this layer which is used for updates.
179187
- `data` is an array of objects (refered to as data elements) to be rendered. Each element **must** have an `id` (unique identifier within the data array) and a `position`. Elements can also contain any additional custom data used for rendering options.
180-
- `icon` provides information about the icon file to use. Icons must be self-hosted, `width` and `height` indicate the dimensions of the icon available at `url`. Only PNG and JPEG files are supported. It can be defined as a "source" for all elements or per element with a function that takes each element as argument and returns the "source" for that element.
188+
- `icon` provides information about the icon file to use. It can be defined as a "source" for all elements or per element with a function that takes each element as argument and returns the "source" for that element. There are 2 options available:
189+
- Option 1: `url` — Icons must be self-hosted, `width` and `height` indicate the "native" dimensions of the icon available at `url`. Only PNG and JPEG files are supported.
190+
- Option 2: `blob` — Instead of a URL, you can pass in a [Javascript Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) that contains the icon file. This lets you pre-load icons in custom ways. Also, it allows for programmatic image manipulation on your icons, prior to passing them to the data layer, e.g. using an offscreen canvas. When using a blob, you should also provide a `blobIdOrHash` string that must be unique for each file/blob you pass in. This hash is not automatic for performance reason, we could result to complex computations, but you are likely to have a simple heuristic to use when passing in the blob. Just like with the url option, `width` and `height` indicate the "native" dimensions of the icon and must be passed in.
181191
- `width` - _optional_ - defines the width of the icon to render in meters. It can be defined as a number for all elements or per element with a function that takes each element as argument and returns the width for that element. _Default value: 1m._
192+
- `colorOverlay` - _optional_ - lets you programmatically control the color of your icons. It applies an overlay of the specified color to the icon. It works best on black and white icons. It can be defined as any valid CSS color string like "orange" or "#3a3c3c", and applied for all elements or per element with a function that takes each element as argument and returns the color string for that element.
182193
- `onDrag, onDrop` - _optional_ - providing either or both handlers will make data elements of the layer draggable. Each handler takes the dragged data element as argument. `onDrop` also receives the new position of the element so it can be updated in your app state and database.
183194
- `disableElevationCorrection` - _optional_
184195
- In 2D mode, the rendered elevation of icons is fully managed and the provided value ignored. Icons will be rendered on top of the floor plans.
185196
- In 3D mode, icons are rendered at their provided elevation but icons with low elevation will automatically be rendered above the ground to avoid being hidden. You can set `disableElevationCorrection` to true to disable this behavior. The elevation value of each icon will then be used directly.
186197
187-
The [Add data elements](/examples/add-data-elements) example gives a full overview of draggable layers, including an icon layer.
198+
The [carpark example](/examples/carpark) demonstrate a number of options available on the icon data layers. The [add data elements](/examples/add-data-elements) example gives a full overview of draggable layers.
188199
189200
### Polygon layer
190201
112 KB
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable import/no-webpack-loader-syntax */
2+
import React from 'react'
3+
4+
import StackblitzProject from '../../../components/StackblitzProject'
5+
6+
import { USE_CASES } from '../_categories'
7+
8+
export const carpark = {
9+
slug: 'carpark',
10+
title: 'Car park',
11+
category: USE_CASES,
12+
description: `Manage car park occupancy and vallet parking with real time lot info and VIP tracking through icons.`,
13+
published: true,
14+
stackblitzProjects: [
15+
{
16+
lang: 'React',
17+
id: 'smplr-carpark-react',
18+
openFile: 'SpaceViewer.tsx',
19+
default: true
20+
}
21+
]
22+
}
23+
24+
export default function () {
25+
return <StackblitzProject project={carpark} />
26+
}

src/pages/examples/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ import { tooltipsOptions } from './tooltips'
3737
import { airQuality } from './air-quality'
3838
import { embeddedEditor } from './embedded-editor'
3939
import { markup } from './markup'
40+
import { carpark } from './carpark'
4041

4142
const projects = [
4243
helloWorld,
4344
spaceBooking,
4445
leasingTenancy,
4546
airQuality,
4647
iot,
48+
carpark,
4749
propertyManagement,
4850
addDataElements,
4951
stackingPlan,

0 commit comments

Comments
 (0)