odoo-addon-web-view-leaflet-map 16.0.2.0.0.3__py3-none-any.whl → 18.0.1.1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. odoo/addons/web_view_leaflet_map/README.rst +96 -83
  2. odoo/addons/web_view_leaflet_map/__manifest__.py +7 -6
  3. odoo/addons/web_view_leaflet_map/hooks.py +4 -4
  4. odoo/addons/web_view_leaflet_map/i18n/fr.po +7 -5
  5. odoo/addons/web_view_leaflet_map/i18n/it.po +7 -5
  6. odoo/addons/web_view_leaflet_map/i18n/web_view_leaflet_map.pot +3 -5
  7. odoo/addons/web_view_leaflet_map/models/ir_ui_view.py +3 -0
  8. odoo/addons/web_view_leaflet_map/readme/CONFIGURE.md +1 -0
  9. odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.md +1 -0
  10. odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.md +23 -0
  11. odoo/addons/web_view_leaflet_map/readme/DEVELOP.md +53 -0
  12. odoo/addons/web_view_leaflet_map/readme/ROADMAP.md +13 -0
  13. odoo/addons/web_view_leaflet_map/static/description/index.html +69 -62
  14. odoo/addons/web_view_leaflet_map/static/description/res_partner_large.png +0 -0
  15. odoo/addons/web_view_leaflet_map/static/description/res_partner_precise.png +0 -0
  16. odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_controller.esm.js +24 -0
  17. odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_controller.xml +24 -0
  18. odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js +275 -0
  19. odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.xml +10 -0
  20. odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_view.esm.js +53 -0
  21. odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/METADATA +212 -0
  22. odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/RECORD +30 -0
  23. {odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info → odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info}/WHEEL +1 -1
  24. odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/top_level.txt +1 -0
  25. odoo/addons/web_view_leaflet_map/readme/CONFIGURE.rst +0 -1
  26. odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.rst +0 -1
  27. odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.rst +0 -11
  28. odoo/addons/web_view_leaflet_map/readme/DEVELOP.rst +0 -62
  29. odoo/addons/web_view_leaflet_map/readme/ROADMAP.rst +0 -8
  30. odoo/addons/web_view_leaflet_map/static/description/res_partner_map.png +0 -0
  31. odoo/addons/web_view_leaflet_map/static/src/js/view/map/map_renderer.js +0 -178
  32. odoo/addons/web_view_leaflet_map/static/src/js/view/map/map_view.js +0 -34
  33. odoo/addons/web_view_leaflet_map/static/src/js/view/view_registry.js +0 -8
  34. odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info/METADATA +0 -199
  35. odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info/RECORD +0 -27
  36. odoo_addon_web_view_leaflet_map-16.0.2.0.0.3.dist-info/top_level.txt +0 -1
  37. /odoo/addons/web_view_leaflet_map/static/src/{css/web_view_leaflet_map.css → views/leaflet_map/leaflet_map_renderer.css} +0 -0
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.1
2
+ Name: odoo-addon-web_view_leaflet_map
3
+ Version: 18.0.1.1.2.1
4
+ Requires-Python: >=3.10
5
+ Requires-Dist: odoo-addon-web_leaflet_lib==18.0.*
6
+ Requires-Dist: odoo==18.0.*
7
+ Summary: Add new 'leaflet_map' view, to display markers.
8
+ Home-page: https://github.com/OCA/geospatial
9
+ License: AGPL-3
10
+ Author: GRAP, Odoo Community Association (OCA)
11
+ Author-email: support@odoo-community.org
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Framework :: Odoo
14
+ Classifier: Framework :: Odoo :: 18.0
15
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
16
+ Description-Content-Type: text/x-rst
17
+
18
+ .. image:: https://odoo-community.org/readme-banner-image
19
+ :target: https://odoo-community.org/get-involved?utm_source=readme
20
+ :alt: Odoo Community Association
21
+
22
+ ================================
23
+ Leaflet Map View (OpenStreetMap)
24
+ ================================
25
+
26
+ ..
27
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28
+ !! This file is generated by oca-gen-addon-readme !!
29
+ !! changes will be overwritten. !!
30
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
+ !! source digest: sha256:74bf9361fbf3e37a4355f272c0cfb21bff1711d71639a7164dfe915bfc7773ab
32
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
+
34
+ .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
35
+ :target: https://odoo-community.org/page/development-status
36
+ :alt: Beta
37
+ .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
38
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
39
+ :alt: License: AGPL-3
40
+ .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fgeospatial-lightgray.png?logo=github
41
+ :target: https://github.com/OCA/geospatial/tree/18.0/web_view_leaflet_map
42
+ :alt: OCA/geospatial
43
+ .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
44
+ :target: https://translation.odoo-community.org/projects/geospatial-18-0/geospatial-18-0-web_view_leaflet_map
45
+ :alt: Translate me on Weblate
46
+ .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
47
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/geospatial&target_branch=18.0
48
+ :alt: Try me on Runboat
49
+
50
+ |badge1| |badge2| |badge3| |badge4| |badge5|
51
+
52
+ This module extends odoo views, to add a new kind of view, named
53
+ ``leaflet_map`` that is using the Leaflet javascript library to use
54
+ maps. (https://leafletjs.com/) This library is for exemple, used in the
55
+ OpenStreetMap project. (https://www.openstreetmap.org/)
56
+
57
+ You can see a simple usage in the module
58
+ ``web_view_leaflet_map_partner`` in the same OCA repository that
59
+ displays your contact in a map, if latitude and longitude are defined.
60
+ (To define latitude and longitude, refer to the Odoo module
61
+ ``base_geolocalize``)
62
+
63
+ A marker will be displayed for each item that has a localization.
64
+
65
+ |image1|
66
+
67
+ If user zooms out, the markers will overlap, which won't be very
68
+ visible.
69
+
70
+ In that case, nearby markers are grouped together, thanks to
71
+ ``Leaflet.markercluster`` plugin.
72
+
73
+ |image2|
74
+
75
+ .. |image1| image:: https://raw.githubusercontent.com/OCA/geospatial/18.0/web_view_leaflet_map/static/description/view_res_partner_map_precise.png
76
+ .. |image2| image:: https://raw.githubusercontent.com/OCA/geospatial/18.0/web_view_leaflet_map/static/description/view_res_partner_map_large.png
77
+
78
+ **Table of contents**
79
+
80
+ .. contents::
81
+ :local:
82
+
83
+ Configuration
84
+ =============
85
+
86
+ - See configuration of the module ``web_leaflet_lib``.
87
+
88
+ Development
89
+ ===========
90
+
91
+ Create a new view :
92
+
93
+ .. code:: xml
94
+
95
+ <record id="view_my_model_map" model="ir.ui.view">
96
+ <field name="model">my.model</field>
97
+ <field name="arch" type="xml">
98
+ <leaflet_map
99
+ field_latitude="FIELD_LATITUDE"
100
+ field_longitude="FIELD_LONGITUDE"
101
+ field_title="FIELD_TITLE"
102
+ field_address="FIELD_ADDRESS"
103
+ field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"
104
+ >
105
+ <field name="__last_update"/>
106
+ <field name="FIELD_LATITUDE"/>
107
+ <field name="FIELD_LONGITUDE"/>
108
+ <field name="FIELD_TITLE"/>
109
+ <field name="FIELD_ADDRESS"/>
110
+ </leaflet_map>
111
+ </field>
112
+ </record>
113
+
114
+ 1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that
115
+ contains GPS coordinates of the model.
116
+ 2. FIELD_TITLE will be used when the popup is displayed, as a title.
117
+ 3. FIELD_ADDRESS will be used when the popup is displayed to display the
118
+ adress.
119
+ 4. (optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to
120
+ place as an icon of the marker. Note: You can set extra settings
121
+ ``marker_icon_size_x``, ``marker_icon_size_y``, to define the size of
122
+ the image, and ``marker_popup_anchor_x``, ``marker_popup_anchor_y``
123
+ to define the position of the popup.
124
+
125
+ Map options :
126
+
127
+ - ``default_zoom`` : define the default zoom value. (7 if not defined)
128
+ - ``max_zoom`` : define the max zoom value. (19 if not defined)
129
+ - ``zoom_snap`` : define the zoom level in each change. (1 if not
130
+ defined)
131
+ - Create or update an action for the model
132
+
133
+ .. code:: xml
134
+
135
+ <record id="my_module.action_my_model" model="ir.actions.act_window">
136
+ <field name="view_mode">tree,form,leaflet_map</field>
137
+ </record>
138
+
139
+ **Default position in the map**
140
+
141
+ By default, the position of the map is defined by the user, in the
142
+ function ``get_default_leaflet_position``. It returns the position of
143
+ the current company, if defined. you can overload this function
144
+ globally, or per model.
145
+
146
+ Known issues / Roadmap
147
+ ======================
148
+
149
+ - For the time being, at the start of the map loading, the call of
150
+ ``invalidateSize()`` is required. We should investigate why and try to
151
+ remove that call. see
152
+ https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
153
+ - For the time being, the map has "Markers" and allow to display odoo
154
+ items if longitude and latitude are available. We could imagine other
155
+ kind of usages, with Polylines, Polygons, etc... See all the leaflet
156
+ options : https://leafletjs.com/reference.html
157
+ - Search bar is not implemented in this view. All records are displayed
158
+ for now. We should:
159
+
160
+ - implement records refresh, when adding / removing domain in the
161
+ search bar.
162
+ - implement a custom search based on the displayed map. (no need to
163
+ load records that are out of the scope of the current displayed
164
+ map).
165
+
166
+ Bug Tracker
167
+ ===========
168
+
169
+ Bugs are tracked on `GitHub Issues <https://github.com/OCA/geospatial/issues>`_.
170
+ In case of trouble, please check there if your issue has already been reported.
171
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
172
+ `feedback <https://github.com/OCA/geospatial/issues/new?body=module:%20web_view_leaflet_map%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
173
+
174
+ Do not contact contributors directly about support or help with technical issues.
175
+
176
+ Credits
177
+ =======
178
+
179
+ Authors
180
+ -------
181
+
182
+ * GRAP
183
+
184
+ Contributors
185
+ ------------
186
+
187
+ - Sylvain LE GAL (https://www.twitter.com/legalsylvain)
188
+
189
+ Maintainers
190
+ -----------
191
+
192
+ This module is maintained by the OCA.
193
+
194
+ .. image:: https://odoo-community.org/logo.png
195
+ :alt: Odoo Community Association
196
+ :target: https://odoo-community.org
197
+
198
+ OCA, or the Odoo Community Association, is a nonprofit organization whose
199
+ mission is to support the collaborative development of Odoo features and
200
+ promote its widespread use.
201
+
202
+ .. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
203
+ :target: https://github.com/legalsylvain
204
+ :alt: legalsylvain
205
+
206
+ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
207
+
208
+ |maintainer-legalsylvain|
209
+
210
+ This module is part of the `OCA/geospatial <https://github.com/OCA/geospatial/tree/18.0/web_view_leaflet_map>`_ project on GitHub.
211
+
212
+ You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
@@ -0,0 +1,30 @@
1
+ odoo/addons/web_view_leaflet_map/README.rst,sha256=jjOnQerGoTIsFBLJeCJnhwWe-h0Fj-0m6-UsJF5XWAY,7333
2
+ odoo/addons/web_view_leaflet_map/__init__.py,sha256=lHbcD_3Jhk02gKyANjQ1Bif8uknO8qLtRSK4lJNPeeQ,55
3
+ odoo/addons/web_view_leaflet_map/__manifest__.py,sha256=WIkj3fDkPC5SPFtzTELQ3rOSkxnYFdLRsPqUUAI4ALs,1296
4
+ odoo/addons/web_view_leaflet_map/hooks.py,sha256=VWhMUWedPCg8oZxqJCladNBaU9NvJMBJI6BlYKXNcEM,685
5
+ odoo/addons/web_view_leaflet_map/i18n/fr.po,sha256=tcE19Q5qGvEAwETvRl01FrgmHxeqreq5hPFvEwmgNV0,2063
6
+ odoo/addons/web_view_leaflet_map/i18n/it.po,sha256=sS-jthG-42w7z3Xp3X-nnEGXp7vvBQ-qFXlN0w8StoE,1722
7
+ odoo/addons/web_view_leaflet_map/i18n/web_view_leaflet_map.pot,sha256=S6I9-CMdFVyClUbdjKkErD7pqqe6GxYYqNJkzMrYRxA,1459
8
+ odoo/addons/web_view_leaflet_map/models/__init__.py,sha256=K0P7QAr_t6UHNt0nbpDhqpH4-zILR1hpfNip3VUtouc,82
9
+ odoo/addons/web_view_leaflet_map/models/ir_act_window_view.py,sha256=NfjklK_VNBCuuXn0X22uQzWr9iOJWeT2oN-qXwwDhqQ,499
10
+ odoo/addons/web_view_leaflet_map/models/ir_ui_view.py,sha256=6K_zmkC44ymIDNycqo2KxFq3brsrd6tvm_JpjIlebdw,518
11
+ odoo/addons/web_view_leaflet_map/models/res_users.py,sha256=SmYcwiVXifiT8pDlb1pdAYnlvnodZ8oOrJHr6GQlle4,545
12
+ odoo/addons/web_view_leaflet_map/readme/CONFIGURE.md,sha256=X0jv_nRhCoSaQ3ZqwOqr8g03pGHv-elXfhX6gIN4ilg,53
13
+ odoo/addons/web_view_leaflet_map/readme/CONTRIBUTORS.md,sha256=MBsB-NNU4QMO7gTa_ZRympiiIQwyMPYqq4M3-PbwbHM,58
14
+ odoo/addons/web_view_leaflet_map/readme/DESCRIPTION.md,sha256=D2_dBJqIgPwUWBL-JnqAXh8LezKNEup1nPB9v10-RBo,878
15
+ odoo/addons/web_view_leaflet_map/readme/DEVELOP.md,sha256=kiVt9qT6SC6Uh9fY0qqSpaI9HSeC67Ppi0b7O7iGPfg,1968
16
+ odoo/addons/web_view_leaflet_map/readme/ROADMAP.md,sha256=LEGUvn8BNbLJ4mgUOA5_wgRLQ96qKzGhk-GRADXu9us,816
17
+ odoo/addons/web_view_leaflet_map/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
18
+ odoo/addons/web_view_leaflet_map/static/description/index.html,sha256=ki_IyFZgzd_LIr2rn29rQDLHUL837Z7B0BPzum3Yuh8,20785
19
+ odoo/addons/web_view_leaflet_map/static/description/res_partner_large.png,sha256=wkjGS9Yc-b5fJEINpp1RwbGMd1DdIkDZVUCC94VYYXs,134800
20
+ odoo/addons/web_view_leaflet_map/static/description/res_partner_precise.png,sha256=wkjGS9Yc-b5fJEINpp1RwbGMd1DdIkDZVUCC94VYYXs,134800
21
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_controller.esm.js,sha256=Y-dTiyZa3BhyoT5qxcgh96CSU1Yzo1P1pHv4XE6qGC0,714
22
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_controller.xml,sha256=qbir26ccYwWLLwFrHDCf4lK0LI1LYVQhdswkEQZywew,802
23
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.css,sha256=Tp3SfDNuSPCN32sh_HlSmiF3AYWlvxlzSp8u3NCAHiA,1527
24
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.esm.js,sha256=PtoiMfYGkdMUUC3kM7eJdo3uQ9xlFVIOqxvfVJ6dI9k,8838
25
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_renderer.xml,sha256=6Mewk0Ak7ILUsj_5gMMPbqvm1iz7CVv_FZ9dmhJY9eQ,315
26
+ odoo/addons/web_view_leaflet_map/static/src/views/leaflet_map/leaflet_map_view.esm.js,sha256=Ueip83K8KxE9KMwNs9fVBsjwkOcbi_khw1qdrJdy1KM,1498
27
+ odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/METADATA,sha256=FqWn_efigxhN7McUVoLZ0qdB6j4e7lJeQul80QlLQ5Q,7948
28
+ odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
29
+ odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
30
+ odoo_addon_web_view_leaflet_map-18.0.1.1.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: Whool 1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1 +0,0 @@
1
- * See configuration of the module ``web_leaflet_lib``.
@@ -1 +0,0 @@
1
- * Sylvain LE GAL (https://www.twitter.com/legalsylvain)
@@ -1,11 +0,0 @@
1
- This module extends odoo views, to add a new kind of view, named ``leaflet_map``
2
- that is using the Leaflet javascript library to use maps. (https://leafletjs.com/)
3
- This library is for exemple, used in the OpenStreetMap project. (https://www.openstreetmap.org/)
4
-
5
- You can see a simple usage in the module ``web_view_leaflet_map_partner`` in the
6
- same OCA repository that displays your contact in a map, if latitude and longitude are
7
- defined. (To define latitude and longitude, refer to the Odoo module ``base_geolocalize``)
8
-
9
- .. figure:: ../static/description/view_res_partner_map_1.png
10
-
11
- .. figure:: ../static/description/view_res_partner_map_2.png
@@ -1,62 +0,0 @@
1
- Create a new view :
2
-
3
- .. code-block:: xml
4
-
5
- <record id="view_my_model_map" model="ir.ui.view">
6
- <field name="model">my.model</field>
7
- <field name="arch" type="xml">
8
- <leaflet_map
9
- field_latitude="FIELD_LATITUDE"
10
- field_longitude="FIELD_LONGITUDE"
11
- field_title="FIELD_TITLE"
12
- field_address="FIELD_ADDRESS"
13
- field_marker_icon_image="FIELD_MARKER_ICON_IMAGE"
14
- >
15
- <field name="__last_update"/>
16
- <field name="FIELD_LATITUDE"/>
17
- <field name="FIELD_LONGITUDE"/>
18
- <field name="FIELD_TITLE"/>
19
- <field name="FIELD_ADDRESS"/>
20
- </leaflet_map>
21
- </field>
22
- </record>
23
-
24
- 1. FIELD_LATITUDE and FIELD_LONGITUDE are the name of the fields that contains GPS coordinates of the model.
25
- 2. FIELD_TITLE will be used when the popup is displayed, as a title.
26
- 3. FIELD_ADDRESS will be used when the popup is displayed to display the adress.
27
- 4. (optional) FIELD_MARKER_ICON_IMAGE, is the name of the image field to place as an icon
28
- of the marker.
29
- Note: You can set extra settings ``marker_icon_size_x``, ``marker_icon_size_y``, to define
30
- the size of the image, and ``marker_popup_anchor_x``, ``marker_popup_anchor_y`` to define
31
- the position of the popup.
32
-
33
- Map options :
34
-
35
- - ``default_zoom`` : define the default zoom value. (7 if not defined)
36
- - ``max_zoom`` : define the max zoom value. (19 if not defined)
37
- - ``zoom_snap`` : define the zoom level in each change. (1 if not defined)
38
-
39
- * Create or update an action for the model
40
-
41
- .. code-block:: xml
42
-
43
- <record id="my_module.action_my_model" model="ir.actions.act_window">
44
- <field name="view_mode">tree,form,leaflet_map</field>
45
- </record>
46
-
47
- **Library Update**
48
-
49
- For the time being, the module embed the lealflet.js library version 1.8.0 ( released on April 18, 2022.)
50
-
51
- If a new release is out:
52
-
53
- - please download it here https://leafletjs.com/download.html
54
- - update the javascript, css and images, present in the folder ``static/lib/leaflet``
55
- - test the features
56
- - make a Pull Request
57
-
58
- **Default position in the map**
59
-
60
- By default, the position of the map is defined by the user, in the function
61
- ``get_default_leaflet_position``. It returns the position of the current company, if defined.
62
- you can overload this function globally, or per model.
@@ -1,8 +0,0 @@
1
- * For the time being, at the start of the map loading, the call of ``invalidateSize()``
2
- is required. We should investigate why and try to remove that call.
3
- see https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
4
-
5
- * For the time being, the map has "Markers" and allow to display odoo items
6
- if longitude and latitude are available. We could imagine other kind of usages,
7
- with Polylines, Polygons, etc...
8
- See all the leaflet options : https://leafletjs.com/reference.html
@@ -1,178 +0,0 @@
1
- odoo.define("web_view_leaflet_map.MapRenderer", function (require) {
2
- "use strict";
3
-
4
- var AbstractRenderer = require("web.AbstractRenderer");
5
- var session = require("web.session");
6
- var field_utils = require("web.field_utils");
7
-
8
- var MapRenderer = AbstractRenderer.extend({
9
- tagName: "div",
10
- className: "o_leaflet_main_container",
11
-
12
- init: function (parent, state, params) {
13
- this._super.apply(this, arguments);
14
-
15
- this.leaflet_tile_url = session["leaflet.tile_url"];
16
- this.leaflet_copyright = session["leaflet.copyright"];
17
- this.default_zoom = params.arch.attrs.default_zoom || 7;
18
- this.max_zoom = params.arch.attrs.max_zoom || 19;
19
- this.zoom_snap = params.arch.attrs.zoom_snap | 1;
20
- this.field_latitude = params.arch.attrs.field_latitude;
21
- this.field_longitude = params.arch.attrs.field_longitude;
22
- this.field_title = params.arch.attrs.field_title;
23
- this.field_address = params.arch.attrs.field_address;
24
- this.field_marker_icon_image = params.arch.attrs.field_marker_icon_image;
25
- this.marker_icon_size_x = params.arch.attrs.marker_icon_size_x || 64;
26
- this.marker_icon_size_y = params.arch.attrs.marker_icon_size_y || 64;
27
- this.marker_popup_anchor_x = params.arch.attrs.marker_popup_anchor_x || 0;
28
- this.marker_popup_anchor_y = params.arch.attrs.marker_popup_anchor_y || -32;
29
- },
30
-
31
- start: function () {
32
- var self = this;
33
- var self_super = this._super;
34
- return this._initDefaultPosition()
35
- .then(function () {
36
- self._initMap();
37
- })
38
- .then(function () {
39
- return self_super.apply(self, arguments);
40
- });
41
- },
42
-
43
- _render: function () {
44
- var self = this;
45
-
46
- // First remove previous layer that contains
47
- // all the previously rendered records
48
- if (this.leaflet_layer_group) {
49
- this.leaflet_map.removeLayer(this.leaflet_layer_group);
50
- }
51
-
52
- // Create a new layer and render fresh records
53
- this.leaflet_layer_group = L.layerGroup().addTo(this.leaflet_map);
54
- _.each(this.state.data, function (record) {
55
- self._renderRecord(record);
56
- });
57
-
58
- // Delay and call invalidateSize() to display correctly
59
- // the map. See.
60
- // https://github.com/Leaflet/Leaflet/issues/3002#issuecomment-93836022
61
- return this._super.apply(this, arguments).then(function () {
62
- window.setTimeout(function () {
63
- self.leaflet_map.invalidateSize();
64
- }, 1);
65
- });
66
- },
67
-
68
- _renderRecord: function (record) {
69
- var self = this;
70
- var latlng = L.latLng(
71
- record.data[this.field_latitude],
72
- record.data[this.field_longitude]
73
- );
74
- // Display only records that have a valid position
75
- if (latlng.lat !== 0 && latlng.lng !== 0) {
76
- // Create marker
77
- var markerOptions = this._prepareMarkerOptions(record);
78
- var marker = L.marker(latlng, markerOptions).addTo(
79
- this.leaflet_layer_group
80
- );
81
-
82
- // Create Popup and attach an event onclick
83
- var popup = L.popup().setContent(this._preparePopUpData(record));
84
-
85
- marker.bindPopup(popup).on("popupopen", () => {
86
- $(".o_map_selector").parent().parent().click(
87
- {
88
- model_name: record.model,
89
- res_id: record.data.id,
90
- current_object: self,
91
- },
92
- self._onClickLeafletPopup
93
- );
94
- });
95
- }
96
- },
97
-
98
- _onClickLeafletPopup: function (ev) {
99
- ev.preventDefault();
100
- ev.data.current_object.trigger_up("switch_view", {
101
- view_type: "form",
102
- res_id: ev.data.res_id,
103
- model: ev.data.model_name,
104
- });
105
- },
106
-
107
- _prepareMarkerIcon: function (record) {
108
- var myIcon = L.icon({
109
- iconUrl: session.url("/web/image", {
110
- model: record.model,
111
- id: JSON.stringify(record.data.id),
112
- field: this.field_marker_icon_image,
113
- // Unique forces a reload of the image when the record has been updated
114
- unique: field_utils.format
115
- .datetime(record.data.__last_update)
116
- .replace(/[^0-9]/g, ""),
117
- }),
118
- className: "leaflet_marker_icon",
119
- iconSize: [this.marker_icon_size_x, this.marker_icon_size_y],
120
- popupAnchor: [this.marker_popup_anchor_x, this.marker_popup_anchor_y],
121
- });
122
- return myIcon;
123
- },
124
-
125
- _prepareMarkerOptions: function (record) {
126
- var icon = this._prepareMarkerIcon(record);
127
- var result = {
128
- title: record.data[this.field_title],
129
- alt: record.data[this.field_title],
130
- riseOnHover: true,
131
- };
132
- if (icon) {
133
- result.icon = icon;
134
- }
135
- return result;
136
- },
137
-
138
- _preparePopUpData: function (record) {
139
- return (
140
- "<div class='o_map_selector' res_id='" +
141
- record.data.id +
142
- "'>" +
143
- "<b>" +
144
- record.data[this.field_title] +
145
- "</b><br/>" +
146
- " - " +
147
- record.data[this.field_address] +
148
- "</div>"
149
- );
150
- },
151
-
152
- _initDefaultPosition: function () {
153
- var self = this;
154
- return this._rpc({
155
- model: "res.users",
156
- method: "get_default_leaflet_position",
157
- args: [this.state.model],
158
- }).then(function (result) {
159
- self.default_lat_lng = L.latLng(result.lat, result.lng);
160
- });
161
- },
162
-
163
- _initMap: function () {
164
- var $mainDiv = $("<div id='div_map' class='o_leaflet_map_container'/>");
165
- this.leaflet_container = $mainDiv[0];
166
- this.leaflet_map = L.map(this.leaflet_container, {
167
- zoomSnap: this.zoom_snap,
168
- }).setView(this.default_lat_lng, this.default_zoom);
169
- this.leaflet_tiles = L.tileLayer(this.leaflet_tile_url, {
170
- maxZoom: this.max_zoom,
171
- attribution: this.leaflet_copyright,
172
- }).addTo(this.leaflet_map);
173
- this.$el.append($mainDiv);
174
- },
175
- });
176
-
177
- return MapRenderer;
178
- });
@@ -1,34 +0,0 @@
1
- odoo.define("web_view_leaflet_map.MapView", function (require) {
2
- "use strict";
3
-
4
- var BasicView = require("web.BasicView");
5
- var core = require("web.core");
6
- var MapRenderer = require("web_view_leaflet_map.MapRenderer");
7
- var _lt = core._lt;
8
-
9
- var MapView = BasicView.extend({
10
- accesskey: "m",
11
- display_name: _lt("Map"),
12
- icon: "fa fa-map-o",
13
- config: _.extend({}, BasicView.prototype.config, {
14
- Renderer: MapRenderer,
15
- }),
16
- viewType: "leaflet_map",
17
- searchMenuTypes: ["filter", "favorite"],
18
-
19
- init: function (viewInfo, params) {
20
- this._super.apply(this, arguments);
21
-
22
- var mode =
23
- this.arch.attrs.editable && !params.readonly ? "edit" : "readonly";
24
-
25
- this.controllerParams.mode = mode;
26
- this.rendererParams.arch = this.arch;
27
-
28
- this.loadParams.limit = this.loadParams.limit || 80;
29
- this.loadParams.type = "list";
30
- },
31
- });
32
-
33
- return MapView;
34
- });
@@ -1,8 +0,0 @@
1
- odoo.define("web_view_leaflet_map.view_registry", function (require) {
2
- "use strict";
3
-
4
- var MapView = require("web_view_leaflet_map.MapView");
5
- var view_registry = require("web.view_registry");
6
-
7
- view_registry.add("leaflet_map", MapView);
8
- });