Add new 'leaflet_map' view, to display markers.
Project description
Leaflet Map View (OpenStreetMap)
This module extends odoo views, to add a new kind of view, named leaflet_map that is using the Leaflet javascript library to use maps. (https://leafletjs.com/) This library is for exemple, used in the OpenStreetMap project. (https://www.openstreetmap.org/)
You can see a simple usage in the module web_view_leaflet_map_partner in the same OCA repository that displays your contact in a map, if latitude and longitude are defined. (To define latitude and longitude, refer to the Odoo module base_geolocalize)
A marker will be displayed for each item that has a localization.
If user zooms out, the markers will overlap, which won’t be very visible.
In that case, nearby markers are grouped together, thanks to Leaflet.markercluster plugin.
Table of contents
Configuration
See configuration of the module web_leaflet_lib.
Development
Create a new view :
<record id="view_my_model_map" model="ir.ui.view">
<field name="model">my.model</field>
<field name="arch" type="xml">
<leaflet_map
field_latitude="FIELD_LATITUDE"
field_longitude="FIELD_LONGITUDE"
field_title="FIELD_TITLE"
field_address="FIELD_ADDRESS"
field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"
>
<field name="__last_update"/>
<field name="FIELD_LATITUDE"/>
<field name="FIELD_LONGITUDE"/>
<field name="FIELD_TITLE"/>
<field name="FIELD_ADDRESS"/>
</leaflet_map>
</field>
</record>
FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that contains GPS coordinates of the model.
FIELD_TITLE will be used when the popup is displayed, as a title.
FIELD_ADDRESS will be used when the popup is displayed to display the adress.
(optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to place as an icon of the marker. Note: You can set extra settings marker_icon_size_x, marker_icon_size_y, to define the size of the image, and marker_popup_anchor_x, marker_popup_anchor_y to define the position of the popup.
Map options :
default_zoom : define the default zoom value. (7 if not defined)
max_zoom : define the max zoom value. (19 if not defined)
zoom_snap : define the zoom level in each change. (1 if not defined)
Create or update an action for the model
<record id="my_module.action_my_model" model="ir.actions.act_window">
<field name="view_mode">tree,form,leaflet_map</field>
</record>
Default position in the map
By default, the position of the map is defined by the user, in the function get_default_leaflet_position. It returns the position of the current company, if defined. you can overload this function globally, or per model.
Known issues / Roadmap
For the time being, at the start of the map loading, the call of invalidateSize() is required. We should investigate why and try to remove that call. see https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
For the time being, the map has “Markers” and allow to display odoo items if longitude and latitude are available. We could imagine other kind of usages, with Polylines, Polygons, etc… See all the leaflet options : https://leafletjs.com/reference.html
Search bar is not implemented in this view. All records are displayed for now. We should:
implement records refresh, when adding / removing domain in the search bar.
implement a custom search based on the displayed map. (no need to load records that are out of the scope of the current displayed map).
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
Sylvain LE GAL (https://www.twitter.com/legalsylvain)
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
Current maintainer:
This module is part of the OCA/geospatial project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_addon_web_view_leaflet_map-18.0.1.1.2.2-py3-none-any.whl.
File metadata
- Download URL: odoo_addon_web_view_leaflet_map-18.0.1.1.2.2-py3-none-any.whl
- Upload date:
- Size: 306.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81bb32cde6cbb5909d4ce3ac77baa075f7051185f71b0588824cf616a8f54187
|
|
| MD5 |
88b4d9b097a2321996620abb3a1db3b9
|
|
| BLAKE2b-256 |
eb06574c9ede1095317484ef5c72aa09312d777754454e28b09338653c9c925f
|