Package: odoo12-addon-web-widget-google-map-drawing
This module extends the Google Map web view in Odoo to allow users to draw
polygons, rectangles, and circles on the map.[![Demo](https://i.ytimg.com/vi/DDUFT6XP8AU/2.jpg)](https://youtu.be/DDUFT6XP8AU“Demo”)More information about the drawing tools can be found [here](https://developers.google.com/maps/documentation/javascript/examples/drawing-tools)This module will support three kind of shapes:
- [Rectangle](https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple)
- [Polygon](https://developers.google.com/maps/documentation/javascript/examples/polygon-simple)
- [Circle](https://developers.google.com/maps/documentation/javascript/examples/polygon-simple)Table of contentsUsageBug TrackerCreditsAuthorsContributorsMaintainersUsageThis 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.## Drawing MixinTo ease the implementation of this feature, a mixin class has been defined that you can use in your modelclassGoogleMapDrawingShapeMixin(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.multidefdecode_shape_paths(self):self.ensure_one()returnsafe_eval(self.shape_paths)How to use the widget<fieldname="shape_paths"widget="map_drawing_shape"/>How to load shape(s) onmapview<recordid="view_res_partner_area_map"model="ir.ui.view"><fieldname="name">view.res.partner.area.map</field><fieldname="model">res.partner.area</field><fieldname="arch"type="xml"><maplibrary="drawing"string="Shape"><fieldname="partner_id"/><fieldname="shape_name"/><fieldname="shape_description"/><fieldname="shape_type"/><fieldname="shape_radius"/><fieldname="shape_area"/><fieldname="shape_paths"/><templates><tt-name="kanban-box"><divclass="oe_kanban_global_click"><divclass="oe_kanban_details"><strongclass="o_kanban_record_title oe_partner_heading"><fieldname="shape_name"/></strong><div><fieldname="shape_description"/></div><divattrs="{'invisible': [('shape_type', 'not in', ['rectangle', 'polygon'])]}">Area:<fieldname="shape_area"/></div><divattrs="{'invisible': [('shape_type', '!=', 'circle')]}">Radius:<fieldname="shape_radius"/></div></div></div></t></templates></map></field></record>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.CreditsAuthorsYopi AngiContributorsYopi Angi <yopiangi@gmail.com>Brian McMaster <brian@mcmpest.com>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.Currentmaintainers:This module is part of theOCA/geospatialproject on GitHub.You are welcome to contribute. To learn how please visithttps://odoo-community.org/page/Contribute.