dcat-admin-7v/latlong-2

纬度 & 经度选择器

v1.5 2020-07-26 14:06 UTC

This package is auto-updated.

Last update: 2024-09-29 01:23:17 UTC


README

这个扩展用于在表单中选择经纬度,该组件支持的地图包括谷歌地图百度地图高德地图腾讯地图Yadex地图

此扩展用于在表单中帮助选择纬度和经度,它用于替代 Laravel-admin 内置的 Form\Field\Map 组件。支持的地图包括 谷歌地图百度地图AMap腾讯地图Yadex地图

安装

composer require dcat-admin-ext/latlong -vvv

配置

打开 config/admin.php 并在扩展部分添加以下配置

    'extensions' => [

        'latlong' => [

            // Whether to enable this extension, defaults to true
            'enable' => true,

            // Specify the default provider
            'default' => 'google',

            // According to the selected provider above, fill in the corresponding api_key
            'providers' => [

                'google' => [
                    'api_key' => '',
                ],
                
                'yadex' => [
                    'api_key' => '',
                ],

                'baidu' => [
                    'api_key' => 'xck5u2lga9n1bZkiaXIHtMufWXQnVhdx',
                ],

                'tencent' => [
                    'api_key' => 'VVYBZ-HRJCX-NOJ4Z-ZO3PU-ZZA2J-QPBBT',
                ],

                'amap' => [
                    'api_key' => '3693fe745aea0df8852739dac08a22fb',
                ],
            ]
        ]
    ]

使用方法

假设你的表中有两个字段 latitudelongitude 代表纬度和经度,那么在表单中使用以下代码

$form->latlong('latitude', 'longitude', 'Position');

// Set the map height
$form->latlong('latitude', 'longitude', 'Position')->height(500);

// Set the map zoom
$form->latlong('latitude', 'longitude', 'Position')->zoom(16);

// Set default position
$form->latlong('latitude', 'longitude', 'Position')->default(['lat' => 90, 'lng' => 90]);

在显示页面中使用

$show->field('Position')->latlong('lat_column', 'long_column', $height = 400, $zoom = 16);

捐赠

如果你觉得这个项目帮到你节省了时间,不妨支持一下;)

-1

许可

MIT许可(MIT)许可。