| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 694 |
| Technical Name |
nz_geo_base |
| License | LGPL-3 |
| Website | https://www.nezam.co |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 694 |
| Technical Name |
nz_geo_base |
| License | LGPL-3 |
| Website | https://www.nezam.co |
NZ Solutions Apps for Odoo
Geo Base — Geo Polygon Map Widget — Odoo 19
Add a fully interactive geographic polygon map field to any Odoo model. Let users draw, edit, and manage zone boundaries directly on an OpenStreetMap map — with numbered markers, midpoint insertion, undo history, GPS location, and instant area calculation.
Usage
Add nz_geo_base to your module's depends list, then use the widget on any Text or Char field:
<field name="my_geo_field" widget="nz_geo_map"/>
Data Format
The field value is stored as JSON:
{"points": [[lat1, lng1], [lat2, lng2], ...], "type": "polygon"}
What does this module provide?
This module provides a reusable OWL field widget (nz_geo_map) that renders an interactive
Leaflet map on any Text or Char field, allowing users to
draw polygon zones by clicking on an OpenStreetMap map;
drag markers to adjust zone boundaries with full undo history;
insert midpoints between existing vertices by hovering a segment and clicking the ghost marker;
and calculate zone area automatically in m² or km². The polygon data is stored as compact JSON
and the widget works in both edit and read-only modes. Install once and reuse the widget in any addon with zero extra assets.
KEY HIGHLIGHTS
Interactive Polygon Drawing
Click anywhere on the OpenStreetMap to add vertices. Each click appends a numbered, draggable marker and the polygon outline updates in real time with a distinctive purple dashed border.
Drag Markers to Reshape
Every vertex marker is draggable. Grab any numbered pin and move it to refine the zone boundary. Dragging is recorded in the undo history so mistakes are instantly reversible.
Insert Midpoint on Hover
Hover over any polygon segment to reveal a ghost + marker at its midpoint. Click it to insert a new vertex exactly there — no need to delete and redraw the zone.
Delete Points with Ease
Left-click a marker to open a popup with a Delete button, or right-click for an instant removal. Both actions are captured in the undo stack so nothing is irreversible.
Undo History & Clear All
Every add, drag, insert, and delete operation is pushed to an undo stack. Hit Undo to step back one action at a time, or use Clear All to reset the entire polygon at once.
Live Area Calculation
The widget auto-calculates the zone area using the spherical Shoelace formula and displays it live in m² or km² as you draw, drag, or delete points.
1) Empty Map — Ready to Draw
When the field has no value, the widget opens an OpenStreetMap centered on Cairo, Egypt at zoom level 13. The toolbar shows Undo, Clear All, Fit to Zone, My Location, and Toggle Numbers buttons. Click anywhere on the map to start placing polygon vertices.

2) Drawing a Polygon — Numbered Markers
Each map click appends a numbered, draggable pin. The widget draws a purple dashed polygon once 3 or more points exist and instantly displays the point count and calculated area in the toolbar. Markers are numbered sequentially so you always know the zone outline.

3) Drag a Marker to Reshape the Zone
Grab any numbered pin and drag it to a new position. The polygon redraws in real time and the area counter updates instantly. The drag start is recorded in the undo history — press Undo to snap the marker back to where it was.

4) Delete a Point — Popup or Right-Click
Left-click a marker to open a Leaflet popup showing the point number and a red Delete this point button. Alternatively, right-click the marker for instant removal. Both methods push a snapshot to the undo stack before deleting.

5) Insert Midpoint — Hover a Segment
Hover over any side of the polygon to reveal a ghost + marker at the segment midpoint. Click it to insert a new vertex exactly between the two neighboring points — the polygon updates immediately and markers are renumbered.

6) Undo & Clear All
The Undo button restores the previous polygon snapshot — every add, drag, insert, and delete is reversible. Clear All removes every marker and resets the field value to an empty polygon, also captured in the undo stack.

7) Toggle Number Labels
The Toggle Numbers button switches marker labels on or off. When off, the pin divs are hidden and only the filled polygon shading remains visible — useful for a clean screenshot or a dense zone with many points.

8) My Location & Fit to Zone
My Location uses the browser Geolocation API to fly the map to the device's GPS position and place a pulsing blue dot. Fit to Zone calls fitBounds on the current polygon so you always see the full zone with 20 % padding regardless of the current zoom level.
{"points": [[lat, lng], ...], "type": "polygon"} compatible with any Text or Char field.nz_geo_map widget in any dependent addon without adding extra JavaScript assets.How do I add the map widget to my own module?
Add nz_geo_base to your module's depends list, then declare the field in your view XML as <field name="my_field" widget="nz_geo_map"/>. The field can be of type Text or Char.
What format is the polygon data stored in?
The value is stored as a JSON string: {"points": [[lat1, lng1], [lat2, lng2], ...], "type": "polygon"}. You can read and process this in Python or JavaScript with a standard JSON parser.
What map tiles does the widget use?
The widget uses OpenStreetMap tiles (tile.openstreetmap.org) via Leaflet.js 1.9.4. No API key is required and the tiles are loaded from a public CDN at no cost.
Where does the map open by default?
When no data exists in the field, the map centers on Cairo, Egypt (30.0444, 31.2357) at zoom 13. When existing polygon data is present, the map auto-fits to the polygon bounds at zoom 15.
How is the zone area calculated?
The widget uses the spherical Shoelace formula with Earth's radius set to 6 371 000 m. Results under 1 km² are displayed in m²; larger zones are shown in km² with two decimal places.
Can I use the widget in read-only views?
Yes. In read-only mode the polygon is rendered with the same purple styling but all editing controls (click-to-add, drag, insert, delete) are disabled. The Fit to Zone and My Location buttons remain active.
Does the My Location button require any server permission?
No server changes are needed. The button calls the standard browser Geolocation API. The user must allow location access in their browser when prompted — no GPS data is sent to the server.
Which Odoo editions and deployment modes are supported?
The module is compatible with Odoo 19 Community and Enterprise on On-Premise, Odoo Online, and Odoo.sh. It depends only on the Web module and has no additional Python dependencies.
Version 19.0.1.0.0
Initial Release- Interactive polygon drawing by clicking on OpenStreetMap
- Numbered, draggable vertex markers with full undo history
- Midpoint ghost marker insertion on segment hover
- Delete-point popup (left-click) and instant right-click removal
- Clear All and Undo Last buttons
- Live area calculation using the spherical Shoelace formula (m² / km²)
- Toggle number labels visibility on all markers
- Fit to Zone — auto-fit map view to polygon bounds
- My Location — GPS fly-to with pulsing blue dot marker
- Read-only mode with polygon preview and no editing controls
- JSON data storage compatible with Text and Char field types
- Reusable OWL widget — install once, use in any addon
- Leaflet.js 1.9.4 loaded on demand — no backend footprint
- Odoo 19 Community & Enterprise support
Please log in to comment on this module