OdooWiki OCA HUB

Google Map View Drawing Mixin

web_widget_google_map_drawing folder_open OCA/geospatial open_in_new
Extra Tools License: AGPL-3

This module extends the Google Map web view in Odoo to allow users to draw polygons, rectangles, and circles on the map.

[](https://youtu.be/DDUFT6XP8AU "Demo")

More information about the drawing tools can be found here

This module will support three kind of shapes:

  • Rectangle
  • Polygon
  • Circle

auto_awesome What this module does

AI-generated from the code · Odoo 12.0

Adds drawing tools to the Google Map view in Odoo, letting users draw a polygon, rectangle or circle on a map field and store its shape, area or radius.

This module extends the Google Map view so that a map field can be used to draw a shape directly on the map instead of typing coordinates.

  • A new field type, map_drawing_shape, is available for text fields. In edit mode it shows a Google map with drawing controls at the bottom for circle, polygon and rectangle.
  • After drawing, the shape stays editable: users can drag it, move its points or change its radius, and the stored value is updated automatically.
  • Only one shape is allowed per field; trying to draw a second one shows a warning.
  • A trash button on the map deletes the selected shape.
  • The module stores the shape type, its area (for polygons), its radius (for circles) and the path/bounds/center coordinates. A helper method decode_shape_paths turns the stored text back into usable data.
  • In read-only mode the saved shape is simply displayed on the map.

Where it appears: - In Settings, under the Google Maps section, a new "Drawing" checkbox turns the Google Maps drawing library on or off. This setting is saved as the google.maps_libraries system parameter. - The drawing widget is added to the backend assets of the Google Map view.

Models touched: google.map.drawing.shape.mixin (an abstract mixin providing the shape fields) and res.config.settings for the Drawing option. Access rights are granted to all internal users.

Models and fields (2)
  • res.config.settings · extends an existing modelgoogle_maps_drawing (Drawing)
  • google.map.drawing.shape.mixin · new modelshape_area (Area), shape_name (Name), shape_type (Type), shape_paths (Paths), shape_radius (Radius), shape_description (Description)

Text generated by AI (DeepSeek) from reading the Odoo 12.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 1 confirmed, 8 with no information of 9 versions.

Sources · Odoo 12.0

Confirmed on 2026-11-03 in branch 12.0 of OCA/geospatial.

terminal Installation and usage

OCA documentation · Odoo 12.0

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.

Drawing Mixin

To ease the implementation of this feature, a mixin class has been defined that you can use in your model

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)

How to use the widget

<field name="shape_paths" widget="map_drawing_shape"/>

How to load shape(s) on map view

<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>

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.