Search 1.9 billion lines of Odoo code on GitHub

web_widget_google_map_drawing

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> &quot;Demo&quot;)</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') &#64;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">&lt;field name=&quot;shape_paths&quot; widget=&quot;map_drawing_shape&quot;/&gt;</code> </pre> <p>How to load shape(s) on <cite>map</cite> view</p> <pre> <code lang="xml">&lt;record id=&quot;view_res_partner_area_map&quot; model=&quot;ir.ui.view&quot;&gt; &lt;field name=&quot;name&quot;&gt;view.res.partner.area.map&lt;/field&gt; &lt;field name=&quot;model&quot;&gt;res.partner.area&lt;/field&gt; &lt;field name=&quot;arch&quot; type=&quot;xml&quot;&gt; &lt;map library=&quot;drawing&quot; string=&quot;Shape&quot;&gt; &lt;field name=&quot;partner_id&quot;/&gt; &lt;field name=&quot;shape_name&quot;/&gt; &lt;field name=&quot;shape_description&quot;/&gt; &lt;field name=&quot;shape_type&quot;/&gt; &lt;field name=&quot;shape_radius&quot;/&gt; &lt;field name=&quot;shape_area&quot;/&gt; &lt;field name=&quot;shape_paths&quot;/&gt; &lt;templates&gt; &lt;t t-name=&quot;kanban-box&quot;&gt; &lt;div class=&quot;oe_kanban_global_click&quot;&gt; &lt;div class=&quot;oe_kanban_details&quot;&gt; &lt;strong class=&quot;o_kanban_record_title oe_partner_heading&quot;&gt; &lt;field name=&quot;shape_name&quot;/&gt; &lt;/strong&gt; &lt;div&gt; &lt;field name=&quot;shape_description&quot;/&gt; &lt;/div&gt; &lt;div attrs=&quot;{'invisible': [('shape_type', 'not in', ['rectangle', 'polygon'])]}&quot;&gt; Area: &lt;field name=&quot;shape_area&quot;/&gt; &lt;/div&gt; &lt;div attrs=&quot;{'invisible': [('shape_type', '!=', 'circle')]}&quot;&gt; Radius: &lt;field name=&quot;shape_radius&quot;/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/t&gt; &lt;/templates&gt; &lt;/map&gt; &lt;/field&gt; &lt;/record&gt;</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 &lt;<a class="reference external" href="mailto:yopiangi&#64;gmail.com">yopiangi&#64;gmail.com</a>&gt;</li> <li>Brian McMaster &lt;<a class="reference external" href="mailto:brian&#64;mcmpest.com">brian&#64;mcmpest.com</a>&gt;</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>