laravel-admin-maps / maps-latlong
经纬度选择器地图
1.0.1
2020-04-26 02:36 UTC
Requires
- php: >=7.0.0
- encore/laravel-admin: ~1.6
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-09-26 12:44:08 UTC
README
这个扩展用于帮助你在表单中选择经纬度,以替代Laravel-admin中内置的Form\Field\Map组件,该组件支持的地图包括Google map、百度地图、高德地图、腾讯地图、Yadex map。
此扩展用于在表单中选择经纬度,用于替换Laravel-admin内置的Form\Field\Map组件。支持的地图包括Google map、百度地图、AMap、腾讯地图、Yadex map。
安装
composer require laravel-admin-maps/maps-latlong
配置
打开 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', ], ] ] ]
使用方法
假设你的表中有两个字段 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);