Package: odoo12-addon-web-view-leaflet-map
This module extends odoo views, to add a new kind of view, namedleaflet_mapthat 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 moduleweb_view_leaflet_map_partnerin 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 modulebase_geolocalize)Important NoteThe javascript library is opensource and distributed under BSD 2 Licence.
See :https://github.com/Leaflet/Leaflet/blob/main/LICENSEYou can so use it freely.However, display maps requires to display layers provided by tiles servers, that
requires ressources.For testing purposeyou can use the openStreetMap urlhttps://tile.openstreetmap.org/{z}/{x}/{y}.pngor other, listed in that page :https://wiki.openstreetmap.org/wiki/Tile_serversApart from very limited testing purposes, you should not use the tiles supplied by OpenStreetMap.org itself. OpenStreetMap is a volunteer-run non-profit body and cannot supply tiles for large-scale commercial use.Regular / High Usageyou can contact one of the following companies :https://switch2osm.org/providers/You can also install yourself your own tiles servers. See documentation :https://switch2osm.org/serving-tiles/ImportantThis is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.More details on development statusTable of contentsConfigurationDevelopmentKnown issues / RoadmapBug TrackerCreditsAuthorsContributorsOther creditsMaintainersConfigurationGo to Settings > Technical > Parameters > System ParametersCreate or edit the parameter with the keyleaflet.tile_urlAs a value, set the url of the tiles server you chose. (See description)DevelopmentCreate a new view :<recordid="view_my_model_map"model="ir.ui.view"><fieldname="model">my.model</field><fieldname="arch"type="xml"><leaflet_mapfield_latitude="FIELD_LATITUDE"field_longitude="FIELD_LONGITUDE"field_title="FIELD_TITLE"field_address="FIELD_ADDRESS"field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"><fieldname="__last_update"/><fieldname="FIELD_LATITUDE"/><fieldname="FIELD_LONGITUDE"/><fieldname="FIELD_TITLE"/><fieldname="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 settingsmarker_icon_size_x,marker_icon_size_y, to define
the size of the image, andmarker_popup_anchor_x,marker_popup_anchor_yto 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<recordid="my_module.action_my_model"model="ir.actions.act_window"><fieldname="view_mode">tree,form,leaflet_map</field></record>Library UpdateFor the time being, the module embed the lealflet.js library version 1.8.0 ( released on April 18, 2022.)If a new release is out:please download it herehttps://leafletjs.com/download.htmlupdate the javascript, css and images, present in the folderstatic/lib/leaflettest the featuresmake a Pull RequestDefault position in the mapBy default, the position of the map is defined by the user, in the functionget_default_leaflet_position. It returns the position of the current company, if defined.
you can overload this function globally, or per model.Known issues / RoadmapFor the time being, at the start of the map loading, the call ofinvalidateSize()is required. We should investigate why and try to remove that call.
seehttps://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022For 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.htmlThe module could not work properly on mobile devices.Bug TrackerBugs are tracked onGitHub 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 welcomedfeedback.Do not contact contributors directly about support or help with technical issues.CreditsAuthorsGRAPContributorsSylvain LE GAL (https://www.twitter.com/legalsylvain)Other creditsThe module embed the Leaflet.js library.MaintainersThis 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.Currentmaintainer:This module is part of theOCA/geospatialproject on GitHub.You are welcome to contribute. To learn how please visithttps://odoo-community.org/page/Contribute.