Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
190d187
Update docusaurus.config.ts
mscno Aug 21, 2024
747011b
deps
mscno Aug 21, 2024
2f7bc3f
add leaflet docs link
mscno Aug 21, 2024
3c9a729
build first version of map libre docs
mscno Sep 18, 2024
0b80cfb
path fix
mscno Sep 18, 2024
55851ea
change header
mscno Sep 18, 2024
2e7f278
fix links
mscno Sep 18, 2024
b7e36a5
tweaks
mscno Sep 18, 2024
8af384a
fix links
mscno Sep 18, 2024
3066293
fix url
mscno Sep 18, 2024
c110cc3
tests
mscno Sep 18, 2024
923a24c
tmp remove all docs
mscno Sep 18, 2024
c6ba871
tweak maplibre
mscno Sep 23, 2024
9490ac7
tweak vercel
mscno Sep 23, 2024
93f56dc
test new baseurkl
mscno Sep 23, 2024
f595c30
test again
mscno Sep 23, 2024
3bd9fd9
fix vercel maplibre
mscno Sep 23, 2024
e361619
update vercel with root redir
mscno Sep 23, 2024
bf5838c
fix path
mscno Sep 23, 2024
c6b8d87
dummy files for all draw/edit/helper modes
zxwild Oct 23, 2024
cd3d4ac
basic demo map for each mode
zxwild Oct 23, 2024
ab970ef
update geoman maplibre version, typing fixes
zxwild Oct 23, 2024
3c27eb4
geojson features, required modes for demo maps
zxwild Oct 24, 2024
aeb14aa
basic documentation for edit modes
zxwild Oct 24, 2024
e4b6931
basic docs for draw modes
zxwild Oct 25, 2024
4f67e87
basic docs for helper modes
zxwild Oct 25, 2024
8b4bedd
basic operations docs: init, events, modes
zxwild Oct 25, 2024
38b810e
typo fixes
zxwild Oct 25, 2024
26b0f8f
events doc fix
zxwild Oct 25, 2024
298cd29
better geoman instantiating, shape markers fix
zxwild Oct 28, 2024
01dd062
more docs for mode handling methods
zxwild Oct 30, 2024
4f94cfa
fix auto enabled states for modes with actions
zxwild Oct 30, 2024
389e9b6
Update 01-basics.md
dailyprice Nov 10, 2024
cf157d8
Merge pull request #1 from geoman-io/doc_updates
mscno Nov 13, 2024
be11a4c
fix unquoted html tags
mscno Nov 13, 2024
7f16a6e
try fix clean urls
mscno Nov 13, 2024
206ec2c
Update index.md
dailyprice Nov 13, 2024
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
Prev Previous commit
Next Next commit
basic operations docs: init, events, modes
  • Loading branch information
zxwild committed Oct 25, 2024
commit 8b4beddc4fce49e0996c7e3ffe59f85243f33a4f
85 changes: 85 additions & 0 deletions docs/01-basics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: "Basic Usage"
---

# Basic Usage

## Installation

```shell
# install pro version
npm install @geoman-io/maplibre-geoman-pro

# or free version
npm install @geoman-io/maplibre-geoman-free
```

## Expected HTML Structure
```html
<!-- index.html -->
<html lang="en_US">
<head>
<title>Geoman Maplibre</title>
<style>
#dev-map {
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<div id="dev-map"></div>
</body>
</html>
```

## Maplibre and Geoman initialization
```typescript
import ml from 'maplibre-gl';
import { type GmOptionsPartial } from '@geoman-io/maplibre-geoman-pro';

import 'maplibre-gl/dist/maplibre-gl.css';
import '@geoman-io/maplibre-geoman-pro/dist/maplibre-geoman.css';


const mapStyle: ml.StyleSpecification = {
version: 8,
glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf',
sources: {
'osm-tiles': {
type: 'raster',
tiles: [
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
],
tileSize: 256,
attribution: '© OpenStreetMap contributors',
},
},
layers: [
{
id: 'osm-tiles-layer',
type: 'raster',
source: 'osm-tiles',
minzoom: 0,
maxzoom: 19,
},
],
};

const map = new ml.Map({
container: 'dev-map',
style: mapLibreStyle,
center: [0, 51],
zoom: 5,
});

const gmOptions: GmOptionsPartial = {
// geoman options here
};

const geoman = new Geoman(gmOptions);
geoman.addControl(map).then(() => {
// geoman is available here as: "geoman" or "map.gm"
console.log('Geoman Controls added');
});
```
27 changes: 27 additions & 0 deletions docs/02-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Events"
---

# Events listening

Events listening is avaiable the same way as for Maplibre. You can listen to all events that are fired by Geoman.
```typescript
// example of listening to the create event
map.on('gm:create', (event: GMEvent) => {
log.debug('Event', event);
});
```

To debug all events you can use the following code. This way you can see all events that are fired by Geoman in the browser console.
```typescript
import { type GlobalEventsListenerParemeters } from '@geoman-io/maplibre-geoman-pro';

map.gm.setGlobalEventsListener((event: GlobalEventsListenerParemeters) => {
if (event.type === 'converted') {
console.log('Regular event', event);
} else if (event.type === 'system') {
console.log('System event', event);
}
});

```
24 changes: 24 additions & 0 deletions docs/03-mode-switching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Modes handing"
---

# Modes handing

All available modes can be enabled/disabled/toggled by the following methods:

For example to handle `edit:drag` mode:
```typescript
// enable mode
map.gm.options.enableMode('edit', 'drag');

// disable mode
map.gm.options.disableMode('edit', 'drag');

// toggle mode
map.gm.options.toggleMode('edit', 'drag');

// check mode state
map.gm.options.isModeEnabled('edit', 'drag');
```

Typescript support is available so you can see available options for each method in the Geoman.
2 changes: 1 addition & 1 deletion docs/draw-modes/00-draw-marker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Marker"
---

## Draw Marker Mode
# Draw Marker Mode

Draw Marker Mode allows you to add markers to the map by clicking on desired locations.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/01-draw-circle_marker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Circle Marker"
---

## Draw Circle Marker Mode
# Draw Circle Marker Mode

Draw Circle Marker Mode allows you to add circle markers to the map. Circle markers are circles with a fixed radius in pixels that maintain their screen size regardless of zoom level.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/02-draw-text_marker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Text Marker"
---

## Draw Text Marker Mode
# Draw Text Marker Mode

Draw Text Marker Mode allows you to add text labels to the map by clicking on desired locations and entering custom text.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/03-draw-circle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Circle"
---

## Draw Circle Mode
# Draw Circle Mode

Draw Circle Mode allows you to add circles to the map by defining a center point and radius.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/04-draw-line.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Line"
---

## Draw Line Mode
# Draw Line Mode

Draw Line Mode allows you to create lines on the map by clicking to add vertices.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/05-draw-rectangle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Rectangle"
---

## Draw Rectangle Mode
# Draw Rectangle Mode

Draw Rectangle Mode allows you to create rectangles on the map by clicking and dragging to define opposite corners.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/06-draw-polygon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Draw Polygon"
---

## Draw Polygon Mode
# Draw Polygon Mode

Draw Polygon Mode allows you to create polygons on the map by clicking to add vertices and closing the shape.

Expand Down
2 changes: 1 addition & 1 deletion docs/draw-modes/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Draw Modes",
"position": 2,
"position": 102,
"collapsible": true,
"link": {
"type": "generated-index"
Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/00-edit-drag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Drag"
---

## Drag Mode
# Drag Mode

You can enable Drag Mode for all layers on a map like this:

Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/01-edit-change.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Edit"
---

## Edit Mode
# Edit Mode

You can enable Edit Mode for all layers on a map like this:

Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/02-edit-rotate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Rotate"
---

## Rotate Mode
# Rotate Mode

You can enable Rotate Mode for all layers on a map like this:

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/03-edit-scale.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Scale"
title: "Scale"
---

## Scale Mode
# Scale Mode

You can enable Scale Mode for all layers on a map like this:

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/04-edit-copy.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Copy"
title: "Copy"
---

## Copy Mode
# Copy Mode

You can enable Copy Mode for all layers on a map like this:

Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/05-edit-cut.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Cut"
---

## Cut Mode
# Cut Mode

Cut mode allows you to cut holes in existing shapes or remove parts of them. You can enable Cut Mode for all layers on a map like this:

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/06-edit-split.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Split"
title: "Split"
---

## Split Mode
# Split Mode

Split Mode allows you to draw a line that splits all underlying Polygons and Lines. When a feature is split, the original feature will be replaced with the resulting split features.

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/07-edit-union.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Union"
title: "Union"
---

## Union Mode
# Union Mode

Union Mode allows you to merge multiple polygons into a single polygon. The original features will be replaced with the resulting union feature.

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/08-edit-difference.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Difference"
title: "Difference"
---

## Difference Mode
# Difference Mode

Difference Mode allows you to subtract one polygon from another. The original feature will be replaced with the resulting difference feature.

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/09-edit-line_simplification.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Line Simplification"
title: "Line Simplification"
---

## Line Simplification Mode
# Line Simplification Mode

Line Simplification Mode allows you to simplify line geometry by removing vertices. This is useful for smoothing complex lines or reducing the number of points in a line.

Expand Down
4 changes: 2 additions & 2 deletions docs/edit-modes/10-edit-lasso.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Lasso"
title: "Lasso"
---

## Lasso Mode
# Lasso Mode

Lasso Mode allows you to select multiple features by drawing a polygon around them. The selection behavior can be configured to either select features that intersect with or are contained within the lasso polygon.

Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/11-edit-delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Remove"
---

## Remove Mode
# Remove Mode

Remove Mode allows you to delete features from the map by clicking on them.

Expand Down
2 changes: 1 addition & 1 deletion docs/edit-modes/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Edit Modes",
"position": 1,
"position": 101,
"collapsible": true,
"link": {
"type": "generated-index"
Expand Down
4 changes: 2 additions & 2 deletions docs/helper-modes/00-helper-snapping.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Snapping Helper"
title: "Snapping"
---

## Snapping Helper Mode
# Snapping Helper Mode

The Snapping Helper Mode enables alignment of features by "snapping" them to nearby elements on the map. This mode provides tools to control, activate, or deactivate snapping for layers or shapes during editing.

Expand Down
4 changes: 2 additions & 2 deletions docs/helper-modes/01-helper-snap_guides.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Snap Guides Helper"
title: "Snap Guides "
---

## Snap Guides Helper Mode
# Snap Guides Helper Mode

The Snap Guides Helper Mode adds visual guidelines that assist in snapping features to specific angles or points during map editing. This mode is useful when precise alignment is necessary while creating or modifying shapes.

Expand Down
4 changes: 2 additions & 2 deletions docs/helper-modes/02-helper-measurements.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Measurements Helper"
title: "Measurements "
---

## Measurements Helper Mode
# Measurements Helper Mode

The Measurements Helper Mode provides tools to display live measurements such as distance, area, and perimeter for various shapes during map editing. This mode works with different shape types to dynamically calculate and display measurements as users draw or modify features.

Expand Down
4 changes: 2 additions & 2 deletions docs/helper-modes/03-helper-pin.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Pin Helper"
title: "Pin "
---

## Pin Helper Mode
# Pin Helper Mode

The Pin Helper Mode allows you to "pin" markers or vertices together, enabling synchronized movement of all connected points when any one of them is dragged. This mode is useful for maintaining alignment across features that share the same coordinates.

Expand Down
4 changes: 2 additions & 2 deletions docs/helper-modes/04-helper-auto_trace.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Auto Trace Helper"
title: "Auto Trace "
---

## Auto Trace Helper Mode
# Auto Trace Helper Mode

The Auto Trace Helper Mode assists users in drawing and connecting shapes by automatically tracing the shortest path between selected points. This mode can be applied to create or complete shapes like lines and polygons by tracing along existing paths.

Expand Down
Loading