Author: |
Yopi Angi, Odoo Community Association (OCA) |
License: |
AGPL-3 |
Branch: |
12.0 |
Repository: |
acsone/geospatial |
Dependencies: |
base_google_map,
and
web_view_google_map |
Languages: |
HTML (409, 44.1%),
JavaScript (327, 35.2%),
Python (81, 8.7%),
XML (48, 5.2%),
and
reStructuredText (63, 6.8%) |
Other repositories: |
Change2improve/geospatial,
ERPLibre/geospatial,
NeatNerdPrime/geospatial,
OCA/geospatial,
anhvu-sg/geospatial,
brian10048/geospatial,
grindtildeath/geospatial,
kmee/geospatial,
sersanchus/geospatial,
and
zarumaru/geospatial |
<h1 class="title">Google Map View Drawing Mixin</h1>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/geospatial/tree/12.0/web_widget_google_map_drawing"><img alt="OCA/geospatial" src="https://img.shields.io/badge/github-OCA%2Fgeospatial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/geospatial-12-0/geospatial-12-0-web_widget_google_map_drawing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/115/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the Google Map web view in Odoo to allow users to draw
polygons, rectangles, and circles on the map.</p>
<p>[![Demo](<a class="reference external" href="https://i.ytimg.com/vi/DDUFT6XP8AU/2.jpg)](https://youtu.be/DDUFT6XP8AU">https://i.ytimg.com/vi/DDUFT6XP8AU/2.jpg)](https://youtu.be/DDUFT6XP8AU</a> "Demo")</p>
<p>More information about the drawing tools can be found [here](<a class="reference external" href="https://developers.google.com/maps/documentation/javascript/examples/drawing-tools">https://developers.google.com/maps/documentation/javascript/examples/drawing-tools</a>)</p>
<p>This module will support three kind of shapes:
- [Rectangle](<a class="reference external" href="https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple">https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple</a>)
- [Polygon](<a class="reference external" href="https://developers.google.com/maps/documentation/javascript/examples/polygon-simple">https://developers.google.com/maps/documentation/javascript/examples/polygon-simple</a>)
- [Circle](<a class="reference external" href="https://developers.google.com/maps/documentation/javascript/examples/polygon-simple">https://developers.google.com/maps/documentation/javascript/examples/polygon-simple</a>)</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<a name="usage"></a>
<h2><a class="toc-backref" href="#id1">Usage</a></h2>
<p>This module provides an extendable framework and cannot be used on its own.
The following provides information on how to implement it for your own module.</p>
<p>## Drawing Mixin</p>
<p>To ease the implementation of this feature, a mixin class has been defined that you can use in your model</p>
<pre>
<code lang="python">class GoogleMapDrawingShapeMixin(models.AbstractModel):
_name = 'google.map.drawing.shape.mixin'
_description = 'Google Maps Shape Mixin'
_rec_name = 'shape_name'
shape_name = fields.Char(string='Name')
shape_area = fields.Float(string='Area')
shape_radius = fields.Float(string='Radius')
shape_description = fields.Text(string='Description')
shape_type = fields.Selection([
('circle', 'Circle'),
('polygon', 'Polygon'),
('rectangle', 'Rectangle')],
string='Type', default='polygon', required=True)
shape_paths = fields.Text(string='Paths')
@api.multi
def decode_shape_paths(self):
self.ensure_one()
return safe_eval(self.shape_paths)</code>
</pre>
<p>How to use the widget</p>
<pre>
<code lang="xml"><field name="shape_paths" widget="map_drawing_shape"/></code>
</pre>
<p>How to load shape(s) on <cite>map</cite> view</p>
<pre>
<code lang="xml"><record id="view_res_partner_area_map" model="ir.ui.view">
<field name="name">view.res.partner.area.map</field>
<field name="model">res.partner.area</field>
<field name="arch" type="xml">
<map library="drawing" string="Shape">
<field name="partner_id"/>
<field name="shape_name"/>
<field name="shape_description"/>
<field name="shape_type"/>
<field name="shape_radius"/>
<field name="shape_area"/>
<field name="shape_paths"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="oe_kanban_details">
<strong class="o_kanban_record_title oe_partner_heading">
<field name="shape_name"/>
</strong>
<div>
<field name="shape_description"/>
</div>
<div attrs="{'invisible': [('shape_type', 'not in', ['rectangle', 'polygon'])]}">
Area: <field name="shape_area"/>
</div>
<div attrs="{'invisible': [('shape_type', '!=', 'circle')]}">
Radius: <field name="shape_radius"/>
</div>
</div>
</div>
</t>
</templates>
</map>
</field>
</record></code>
</pre>
<a name="bug-tracker"></a>
<h2><a class="toc-backref" href="#id2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/geospatial/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/geospatial/issues/new?body=module:%20web_widget_google_map_drawing%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
<a name="credits"></a>
<h2><a class="toc-backref" href="#id3">Credits</a></h2>
<a name="authors"></a>
<h3><a class="toc-backref" href="#id4">Authors</a></h3>
<ul class="simple">
<li>Yopi Angi</li>
</ul>
<a name="contributors"></a>
<h3><a class="toc-backref" href="#id5">Contributors</a></h3>
<ul class="simple">
<li>Yopi Angi <<a class="reference external" href="mailto:yopiangi@gmail.com">yopiangi@gmail.com</a>></li>
<li>Brian McMaster <<a class="reference external" href="mailto:brian@mcmpest.com">brian@mcmpest.com</a>></li>
</ul>
<a name="maintainers"></a>
<h3><a class="toc-backref" href="#id6">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/gityopie"><img alt="gityopie" src="https://github.com/gityopie.png?size=40px" /></a> <a class="reference external" href="https://github.com/brian10048"><img alt="brian10048" src="https://github.com/brian10048.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/geospatial/tree/12.0/web_widget_google_map_drawing">OCA/geospatial</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>