|
| 1 | +================================ |
| 2 | +Leaflet Map View (OpenStreetMap) |
| 3 | +================================ |
| 4 | + |
| 5 | +.. |
| 6 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 7 | + !! This file is generated by oca-gen-addon-readme !! |
| 8 | + !! changes will be overwritten. !! |
| 9 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 10 | + !! source digest: sha256:f494ec35cbd29ae4bcc5e46a7a30bf5b2261bd449a3b0ba08a95a70d45dbea12 |
| 11 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 12 | +
|
| 13 | +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png |
| 14 | + :target: https://odoo-community.org/page/development-status |
| 15 | + :alt: Alpha |
| 16 | +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png |
| 17 | + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
| 18 | + :alt: License: AGPL-3 |
| 19 | +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fgeospatial-lightgray.png?logo=github |
| 20 | + :target: https://github.com/OCA/geospatial/tree/17.0/web_view_leaflet_map |
| 21 | + :alt: OCA/geospatial |
| 22 | +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
| 23 | + :target: https://translation.odoo-community.org/projects/geospatial-17-0/geospatial-17-0-web_view_leaflet_map |
| 24 | + :alt: Translate me on Weblate |
| 25 | +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png |
| 26 | + :target: https://runboat.odoo-community.org/builds?repo=OCA/geospatial&target_branch=17.0 |
| 27 | + :alt: Try me on Runboat |
| 28 | + |
| 29 | +|badge1| |badge2| |badge3| |badge4| |badge5| |
| 30 | + |
| 31 | +This module extends odoo views, to add a new kind of view, named |
| 32 | +``leaflet_map`` that is using the Leaflet javascript library to use |
| 33 | +maps. (https://leafletjs.com/) This library is for exemple, used in the |
| 34 | +OpenStreetMap project. (https://www.openstreetmap.org/) |
| 35 | + |
| 36 | +You can see a simple usage in the module |
| 37 | +``web_view_leaflet_map_partner`` in the same OCA repository that |
| 38 | +displays your contact in a map, if latitude and longitude are defined. |
| 39 | +(To define latitude and longitude, refer to the Odoo module |
| 40 | +``base_geolocalize``) |
| 41 | + |
| 42 | +|image1| |
| 43 | + |
| 44 | +|image2| |
| 45 | + |
| 46 | +.. |image1| image:: https://raw.githubusercontent.com/OCA/geospatial/17.0/web_view_leaflet_map/static/description/view_res_partner_map_1.png |
| 47 | +.. |image2| image:: https://raw.githubusercontent.com/OCA/geospatial/17.0/web_view_leaflet_map/static/description/view_res_partner_map_2.png |
| 48 | + |
| 49 | +.. IMPORTANT:: |
| 50 | + This is an alpha version, the data model and design can change at any time without warning. |
| 51 | + Only for development or testing purpose, do not use in production. |
| 52 | + `More details on development status <https://odoo-community.org/page/development-status>`_ |
| 53 | + |
| 54 | +**Table of contents** |
| 55 | + |
| 56 | +.. contents:: |
| 57 | + :local: |
| 58 | + |
| 59 | +Configuration |
| 60 | +============= |
| 61 | + |
| 62 | +- See configuration of the module ``web_leaflet_lib``. |
| 63 | + |
| 64 | +Development |
| 65 | +=========== |
| 66 | + |
| 67 | +Create a new view : |
| 68 | + |
| 69 | +.. code:: xml |
| 70 | +
|
| 71 | + <record id="view_my_model_map" model="ir.ui.view"> |
| 72 | + <field name="model">my.model</field> |
| 73 | + <field name="arch" type="xml"> |
| 74 | + <leaflet_map |
| 75 | + field_latitude="FIELD_LATITUDE" |
| 76 | + field_longitude="FIELD_LONGITUDE" |
| 77 | + field_title="FIELD_TITLE" |
| 78 | + field_address="FIELD_ADDRESS" |
| 79 | + field_marker_icon_image="FIELD_MARKER_ICON_IMAGE" |
| 80 | + > |
| 81 | + <field name="__last_update"/> |
| 82 | + <field name="FIELD_LATITUDE"/> |
| 83 | + <field name="FIELD_LONGITUDE"/> |
| 84 | + <field name="FIELD_TITLE"/> |
| 85 | + <field name="FIELD_ADDRESS"/> |
| 86 | + </leaflet_map> |
| 87 | + </field> |
| 88 | + </record> |
| 89 | +
|
| 90 | +1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that |
| 91 | + contains GPS coordinates of the model. |
| 92 | +2. FIELD_TITLE will be used when the popup is displayed, as a title. |
| 93 | +3. FIELD_ADDRESS will be used when the popup is displayed to display the |
| 94 | + adress. |
| 95 | +4. (optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to |
| 96 | + place as an icon of the marker. Note: You can set extra settings |
| 97 | + ``marker_icon_size_x``, ``marker_icon_size_y``, to define the size of |
| 98 | + the image, and ``marker_popup_anchor_x``, ``marker_popup_anchor_y`` |
| 99 | + to define the position of the popup. |
| 100 | + |
| 101 | +Map options : |
| 102 | + |
| 103 | +- ``default_zoom`` : define the default zoom value. (7 if not defined) |
| 104 | +- ``max_zoom`` : define the max zoom value. (19 if not defined) |
| 105 | +- ``zoom_snap`` : define the zoom level in each change. (1 if not |
| 106 | + defined) |
| 107 | +- Create or update an action for the model |
| 108 | + |
| 109 | +.. code:: xml |
| 110 | +
|
| 111 | + <record id="my_module.action_my_model" model="ir.actions.act_window"> |
| 112 | + <field name="view_mode">tree,form,leaflet_map</field> |
| 113 | + </record> |
| 114 | +
|
| 115 | +**Library Update** |
| 116 | + |
| 117 | +For the time being, the module embed the lealflet.js library version |
| 118 | +1.8.0 ( released on April 18, 2022.) |
| 119 | + |
| 120 | +If a new release is out: |
| 121 | + |
| 122 | +- please download it here https://leafletjs.com/download.html |
| 123 | +- update the javascript, css and images, present in the folder |
| 124 | + ``static/lib/leaflet`` |
| 125 | +- test the features |
| 126 | +- make a Pull Request |
| 127 | + |
| 128 | +**Default position in the map** |
| 129 | + |
| 130 | +By default, the position of the map is defined by the user, in the |
| 131 | +function ``get_default_leaflet_position``. It returns the position of |
| 132 | +the current company, if defined. you can overload this function |
| 133 | +globally, or per model. |
| 134 | + |
| 135 | +Known issues / Roadmap |
| 136 | +====================== |
| 137 | + |
| 138 | +- For the time being, at the start of the map loading, the call of |
| 139 | + ``invalidateSize()`` is required. We should investigate why and try |
| 140 | + to remove that call. see |
| 141 | + https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022 |
| 142 | +- For the time being, the map has "Markers" and allow to display odoo |
| 143 | + items if longitude and latitude are available. We could imagine other |
| 144 | + kind of usages, with Polylines, Polygons, etc... See all the leaflet |
| 145 | + options : https://leafletjs.com/reference.html |
| 146 | + |
| 147 | +Bug Tracker |
| 148 | +=========== |
| 149 | + |
| 150 | +Bugs are tracked on `GitHub Issues <https://github.com/OCA/geospatial/issues>`_. |
| 151 | +In case of trouble, please check there if your issue has already been reported. |
| 152 | +If you spotted it first, help us to smash it by providing a detailed and welcomed |
| 153 | +`feedback <https://github.com/OCA/geospatial/issues/new?body=module:%20web_view_leaflet_map%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
| 154 | + |
| 155 | +Do not contact contributors directly about support or help with technical issues. |
| 156 | + |
| 157 | +Credits |
| 158 | +======= |
| 159 | + |
| 160 | +Authors |
| 161 | +------- |
| 162 | + |
| 163 | +* GRAP |
| 164 | + |
| 165 | +Contributors |
| 166 | +------------ |
| 167 | + |
| 168 | +- Sylvain LE GAL (https://www.twitter.com/legalsylvain) |
| 169 | + |
| 170 | +Maintainers |
| 171 | +----------- |
| 172 | + |
| 173 | +This module is maintained by the OCA. |
| 174 | + |
| 175 | +.. image:: https://odoo-community.org/logo.png |
| 176 | + :alt: Odoo Community Association |
| 177 | + :target: https://odoo-community.org |
| 178 | + |
| 179 | +OCA, or the Odoo Community Association, is a nonprofit organization whose |
| 180 | +mission is to support the collaborative development of Odoo features and |
| 181 | +promote its widespread use. |
| 182 | + |
| 183 | +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px |
| 184 | + :target: https://github.com/legalsylvain |
| 185 | + :alt: legalsylvain |
| 186 | + |
| 187 | +Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: |
| 188 | + |
| 189 | +|maintainer-legalsylvain| |
| 190 | + |
| 191 | +This module is part of the `OCA/geospatial <https://github.com/OCA/geospatial/tree/17.0/web_view_leaflet_map>`_ project on GitHub. |
| 192 | + |
| 193 | +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
0 commit comments