跳转到主要内容

向Odoo中的Google地图视图添加绘图工具

项目描述

Beta License: AGPL-3 OCA/geospatial Translate me on Weblate Try me on Runboat

此模块扩展了Odoo中的Google地图网络视图,允许用户在地图上绘制多边形、矩形和圆。

[![演示](https://i.ytimg.com/vi/DDUFT6XP8AU/2.jpg)](https://youtu.be/DDUFT6XP8AU) “演示”)

有关绘图工具的更多信息,请参阅[此处](https://developers.google.com/maps/documentation/javascript/examples/drawing-tools)

此模块将支持三种形状:- [矩形](https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple) - [多边形](https://developers.google.com/maps/documentation/javascript/examples/polygon-simple) - [圆](https://developers.google.com/maps/documentation/javascript/examples/polygon-simple)

目录

使用方法

此模块提供了一个可扩展的框架,不能单独使用。以下提供了有关如何将其用于您自己的模块的信息。

## 绘图混入

为了简化该功能的实现,已定义了一个混入类,您可以在模型中使用它

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)

如何使用小部件

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

如何在地图视图中加载形状

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

错误跟踪器

错误在 GitHub Issues 上跟踪。如果遇到问题,请检查是否已经有人报告了相同的问题。如果是您首先发现的,请通过提供详细且受欢迎的 反馈 来帮助我们解决问题。

请不要直接联系贡献者寻求支持或技术问题帮助。

致谢

作者

  • Yopi Angi

贡献者

维护者

此模块由OCA维护。

Odoo Community Association

OCA,即Odoo社区协会,是一个非营利组织,其使命是支持Odoo功能的协作开发并推广其广泛应用。

当前 维护者

gityopie brian10048

此模块是GitHub上的 OCA/geospatial 项目的一部分。

欢迎您贡献力量。了解详情请访问 https://odoo-community.org/page/Contribute

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

本版本没有可用的源代码分发文件。请参阅 生成分发存档的教程

构建分发

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面