jushi/latlong

纬度 & 经度选择器

1.2 2019-11-28 02:55 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:47 UTC


README

这个扩展用于帮助你在表单中选择经纬度,用于替代 Laravel-admin 中内置的 Form\Field\Map 组件,组件支持的地图包括 Google 地图百度地图高德地图腾讯地图Yadex 地图

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

安装

composer require laravel-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) 下授权。