Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add documentation for 'change:extent' event #13

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased
### Added
- Documentation for the "change:extent" event
- `CadenzaClient#setFilter`
- `CadenzaClient#selectObjects`
- Documentation for the "JSON Representation of Cadenza Object Data"
Expand Down
6 changes: 6 additions & 0 deletions src/cadenza.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class CadenzaClient {
* @return {Promise<void>} A `Promise` for when the iframe is loaded
* @throws For invalid arguments
* @fires {@link CadenzaDrillThroughEvent}
* @fires {@link CadenzaChangeExtentEvent}
*/
show(
source,
Expand Down Expand Up @@ -264,6 +265,7 @@ export class CadenzaClient {
* @return {Promise<void>} A `Promise` for when the iframe is loaded
* @throws For invalid arguments
* @fires {@link CadenzaDrillThroughEvent}
* @fires {@link CadenzaChangeExtentEvent}
*/
async showMap(
mapView,
Expand Down Expand Up @@ -879,6 +881,10 @@ function createParams({
* <p>
* See also: <a href="../index.html#md:json-representation-of-cadenza-object-data">JSON Representation of Cadenza Object Data</a>
*/
/**
* @typedef {CadenzaEvent<'change:extent', {extent: Extent}>} CadenzaChangeExtentEvent - When the user moved the map.
* The extent is transformed according to the `useMapSrs` option.
*/
/** @typedef {CadenzaEvent<'editGeometry:update', {geometry: Geometry}>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. */
/** @typedef {CadenzaEvent<'editGeometry:ok', {geometry: Geometry}>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
/** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
Expand Down
13 changes: 13 additions & 0 deletions src/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ const unsubscribe = cadenzaClient.on('editGeometry:ok', (event) => ...);
unsubscribe();
```

### Subscribe to map extent change

Subscribe to `extent:change` event to be notified about map extent changes. The event details contain the new map extent (transformed to EPSG:4326):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's change:extent. But if I look at the example - maybe it's not really necessary, because the event is documented in the api docs and we already have an example for subscribing to an event in TS. What do you think?

If you keep the example (and resolved the above comment), you should use the CadenzaChangeExtentEvent type.


```typescript
cadenzaClient.on(
'change:extent',
(event: CadenzaEvent<{ extent: Extent }>) => {
console.log('Map extent has been changed to:', event.detail.extent);
},
);
```

### Create a New Geometry

<small>API: [CadenzaClient#createGeometry](./classes/CadenzaClient.html#createGeometry)</small>
Expand Down
Loading