腾讯地图

组件说明

腾讯地图组件用于在表单中选择地理位置,基于腾讯地图API实现。

用法示例

use plugin\xbCode\builder\Builder;
use plugin\xbCode\builder\Renders\Form;
use plugin\xbCode\builder\Components\Form\LocationPicker;

Builder::form(function (Form $builder) {
    // 添加腾讯地图组件 (使用LocationPicker组件并设置vendor为tencent)
    $component = $builder->addRow(LocationPicker::class, 'address', '地址选择', '');
    $component->vendor('tencent'); // 设置为腾讯地图
    $component->ak('your-tencent-map-ak'); // 设置腾讯地图Key
    $component->coordinatesType('gcj02'); // 腾讯地图使用gcj02坐标系
    $component->placeholder('请选择地址');
    $component->autoSelectCurrentLoc(true);

    // 或链式调用
    $builder->addRow(LocationPicker::class, 'location', '位置', '')
        ->vendor('tencent')
        ->ak('your-tencent-map-ak')
        ->coordinatesType('gcj02')
        ->clearable(true);
});

组件参数

参数名类型默认值说明
namestring-字段名称
labelstring-字段标签
valuemixed-默认值
vendorstring'tencent'地图厂商,设置为tencent(腾讯地图)
akstring-腾讯地图的Key密钥(必填)
coordinatesTypestring'gcj02'坐标系类型,腾讯地图使用gcj02坐标系
staticboolfalse是否静态展示
clearableboolfalse输入框是否可清空
placeholderstring-默认提示文本
autoSelectCurrentLocboolfalse是否自动选中当前地理位置
onlySelectCurrentLocboolfalse是否限制只能选中当前地理位置
staticSchemaarray-静态展示额外配置
requiredboolfalse是否必填
disabledboolfalse是否禁用
hiddenboolfalse是否隐藏

使用说明

  1. 使用前需要申请腾讯地图Key密钥
  2. 腾讯地图使用gcj02坐标系(国测局坐标系)
  3. 组件会返回包含经纬度和地址信息的对象
  4. 支持点击地图选择位置或搜索地址
  5. 与高德地图使用相同的坐标系,数据可互通