You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
// For laravel-admin 1.x
composer require laravel-admin-ext/latlong:1.x -vvv
// For laravel-admin 2.x
composer require laravel-admin-ext/latlong:2.x -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' => 'google',
// According to the selected provider above, fill in the corresponding api_key'providers' => [
'google' => [
'api_key' => '',
],
'yandex' => [
'api_key' => '',
],
'baidu' => [
'api_key' => 'xck5u2lga9n1bZkiaXIHtMufWXQnVhdx',
],
'tencent' => [
'api_key' => 'VVYBZ-HRJCX-NOJ4Z-ZO3PU-ZZA2J-QPBBT',
],
'amap' => [
'api_key' => '3693fe745aea0df8852739dac08a22fb',
],
]
]
]
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]);