Skip to content

Commit

Permalink
feat: marker tooltips (LAN-814)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Jan 30, 2024
1 parent c8fd4b8 commit 7835f27
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ When `only_id` is not enabled, the response is a list of dictionaries, like this
}
```

> [!NOTE]
> Read more about the `geojson` property [here](geojson.md).
When `only_id` is enabled, the response is a list of strings, like this:

```json
Expand Down
90 changes: 90 additions & 0 deletions docs/geojson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
The `location` field in **Water Body** contains a GeoJSON object.

This is available via the API endpoint [`/api/method/landa.api.water_body`](api.md#water-body). In the API response, the property is called `geojson`.

The GeoJSON object contains a `FeatureCollection`, for example:

```js
{
"type": "FeatureCollection",
"features": [
{ // water body area
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[14.326696, 51.174984],
[14.326345, 51.17503],
[14.324878, 51.175383],
[14.323545, 51.175964],
[14.323442, 51.17628],
[14.323064, 51.17645],
[14.323376, 51.177352],
[14.324741, 51.176883],
[14.326346, 51.176331],
[14.327334, 51.176162],
[14.327485, 51.176114],
[14.327215, 51.175865],
[14.327004, 51.175578],
[14.326856, 51.17531],
[14.326696, 51.174984]
]
]
},
},
{ // restricted area
"type": "Feature",
"properties": { "is_restricted_area": true },
"geometry": {
"type": "Polygon",
"coordinates": [
[
[14.323533, 51.177293],
[14.323232, 51.177468],
[14.322867, 51.176466],
[14.323136, 51.176418],
[14.323329, 51.176324],
[14.323457, 51.17621],
[14.323597, 51.17623],
[14.323479, 51.176405],
[14.323221, 51.176492],
[14.323533, 51.177293]
]
]
}
},
{ // default marker
"type": "Feature",
"properties": {},
"geometry": { "type": "Point", "coordinates": [14.322559, 51.175095] }
},
{ // default marker with tooltip
"type": "Feature",
"properties": { "tooltip": "Yay!" },
"geometry": { "type": "Point", "coordinates": [14.324146, 51.174597] }
},
{ // marker with custom icon
"type": "Feature",
"properties": {
"point_type": "custom-icon",
"icon": "hs-gelb-f-gelb",
"rotation_angle": 0
},
"geometry": { "type": "Point", "coordinates": [14.324627, 51.174543] }
},
{ // marker with custom icon and tooltip
"type": "Feature",
"properties": {
"point_type": "custom-icon",
"icon": "hs-gelb-f-rot",
"rotation_angle": 0,
"tooltip": "Yay!"
},
"geometry": { "type": "Point", "coordinates": [14.326644, 51.174287] }
}
]
}
```

The icon URL for a given icon name can be obtained via the API endpoint [`/api/method/landa.api.custom_icon`](api.md#custom-icon).
3 changes: 2 additions & 1 deletion landa/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Privacy Policy,Datenschutzerklärung,
Imprint,Impressum,
Toggle HTML,HTML umschalten,
Rent per Year,Pachtzins pro Jahr,
Icon,Symbol,
Marker Icon,Marker-Symbol,
Marker Tooltip,Marker-Bemerkung,
Custom Marker,Spezielle Markierungen,
Please attach an icon file.,Bitte hängen Sie eine Symbol-Datei an.,
Special Yearly Fishing Permits,Erlaubnisscheine Gewässerfonds,
Expand Down
14 changes: 10 additions & 4 deletions landa/water_body_management/doctype/water_body/water_body.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"custom_marker_section",
"icon",
"rotation",
"marker_tooltip",
"draw_restricted_area",
"column_break_jorfc",
"icon_path",
Expand Down Expand Up @@ -231,16 +232,16 @@
{
"fieldname": "icon",
"fieldtype": "Link",
"label": "Icon",
"label": "Marker Icon",
"options": "Custom Icon",
"permlevel": 2
},
{
"depends_on": "icon",
"fieldname": "rotation",
"fieldtype": "HTML",
"label": "Rotation",
"options": "<label for=\"icon_rotation\">Drehung</label>\n<input class=\"custom-range\" id=\"icon_rotation\" max=\"180\" min=\"-180\" step=\"15\" type=\"range\">",
"label": "Marker Rotation",
"options": "<label for=\"icon_rotation\">Marker-Drehung</label>\n<input class=\"custom-range\" id=\"icon_rotation\" max=\"180\" min=\"-180\" step=\"15\" type=\"range\">",
"permlevel": 2
},
{
Expand Down Expand Up @@ -274,6 +275,11 @@
"fieldname": "draw_restricted_area",
"fieldtype": "Check",
"label": "Draw Restricted Area"
},
{
"fieldname": "marker_tooltip",
"fieldtype": "Data",
"label": "Marker Tooltip"
}
],
"links": [
Expand All @@ -290,7 +296,7 @@
"link_fieldname": "water_body"
}
],
"modified": "2023-12-02 23:40:21.167172",
"modified": "2024-01-30 19:15:40.621623",
"modified_by": "Administrator",
"module": "Water Body Management",
"name": "Water Body",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def before_save(self):
self.icon_path = None
self.icon_preview = None
self.draw_restricted_area = 0
self.marker_tooltip = None


def rebuild_water_body_cache(fishing_area: str = None, enqueued: bool = False):
Expand Down

0 comments on commit 7835f27

Please sign in to comment.