antto1/laravel-admin-ext-latlong

Latitude & Longitude selector

v1.2.2 2020-11-30 08:24 UTC

This package is auto-updated.

Last update: 2024-10-29 05:53:37 UTC


README

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

This extension is used to help you select the latitude and longitude in the form, which is used to replace the Laravel-admin built in Form\Field\Map component. The supported maps include Google map, Baidu map, AMap, Tencent Map, Yandex map.

Installation

composer require antto1/laravel-admin-ext-latlong -vvv

Configuration

Open config/admin.php and add the following configuration to the extensions section:

    'extensions' => [

        'latlong' => [

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

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

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

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

                'yandex' => [
                    'api_key' => '',
                ],

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

                'tencent' => [
                    'api_key' => '',
                ],

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

Usage

Suppose you have two fields latitude and longitude in your table that represent latitude and longitude, then use the following in the form:

$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]);

Use in show page

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

Licensed under The MIT License (MIT).