diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d4b362 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +phpunit.phar +/vendor +composer.phar +composer.lock +*.project +.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..229071a --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jens Segers + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 39ba139..94dbf9a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,85 @@ -# laravel-admin-ext-latlong +Latitude and longitude selector +====== +这个扩展用来帮助你在form表单中选择经纬度,用来替代`Laravel-admin`中内置的`Form\Field\Map`组件, 组件支持的地图包括`Google map`、`百度地图`、`高德地图`、`腾讯地图`、`Yadex 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`, `Yadex map`. + +## Installation + +```bash +composer require laravel-admin-ext/latlong -vvv +``` + +## Configuration + +Open `config/admin.php` and add the following configuration to the extensions section: + +```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', + ], + ] + ] + ] + +``` + +## Usage + +Suppose you have two fields `latitude` and `longitude` in your table that represent latitude and longitude, then use the following in the form: +```php +$form->latlong('latitude', 'longitude', 'Position'); + +// Set the map height +$form->latlong('latitude', 'longitude', 'Position')->height(500); + +// Set default position +$form->latlong('latitude', 'longitude', 'Position')->default(['lat' => 90, 'lng' => 90]); +``` + +Use in show page + +```php +$show->field('Position')->latlong('lat_column', 'long_column', $height = 400); +``` + +## Donate + +如果觉得这个项目帮你节约了时间,不妨支持一下;) + + + +License +------------ +Licensed under [The MIT License (MIT)](LICENSE). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..66fe7a0 --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ + "name": "aix/latlong", + "description": "Latitude & Longitude selector", + "type": "library", + "keywords": ["laravel-admin", "extension"], + "homepage": "https://github.com/laravel-admin-ext/latlong", + "license": "MIT", + "authors": [ + { + "name": "z-song", + "email": "zosong@126.com" + } + ], + "require": { + "php": ">=7.0.0", + "aix/laravel-admin": "1.0.*" + }, + "require-dev": { + "phpunit/phpunit": "~6.0" + }, + "autoload": { + "psr-4": { + "Encore\\Admin\\Latlong\\": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "Encore\\Admin\\Latlong\\LatlongServiceProvider" + ] + } + } +} diff --git a/resources/views/latlong.blade.php b/resources/views/latlong.blade.php new file mode 100644 index 0000000..838e72e --- /dev/null +++ b/resources/views/latlong.blade.php @@ -0,0 +1,38 @@ +