antto1 / laravel-admin-ext-latlong
经纬度选择器
v1.2.2
2020-11-30 08:24 UTC
Requires
- php: >=7.0.0
- antto1/laravel-admin: ^2.0|^3.0
Requires (Dev)
- phpunit/phpunit: ~6.0
README
这个扩展用于帮助您在表单中选择经纬度,用于替代Laravel-admin中内置的Form\Field\Map组件,该组件支持的地图包括Google map、百度地图、高德地图、腾讯地图、Yandex map。
此扩展用于帮助您在表单中选择经纬度,用于替代Laravel-admin内置的Form\Field\Map组件。支持的地图包括Google map、百度地图、AMap、腾讯地图、Yandex map。
安装
composer require antto1/laravel-admin-ext-latlong -vvv
配置
打开config/admin.php文件,并在extensions部分添加以下配置
'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' => '', ], ] ] ]
用法
假设您的表中有两个字段latitude和longitude代表经纬度,那么在表单中可以使用以下代码
$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);
许可协议:[The MIT License (MIT)](https://github.com/antto1/laravel-admin-ext-latlong/blob/HEAD/LICENSE)