devops / nova-map-address
一个 Laravel Nova 字段,可以在地图上放置标记以获取坐标,然后通过反向地理编码获取街道地址
dev-master
2021-01-05 20:58 UTC
Requires
- php: >=7.1.0
- illuminate/support: ^5.7|^6.0|^7.0|^8.0
This package is auto-updated.
Last update: 2024-09-06 04:54:34 UTC
README
一个 Nova 字段,可以在地图上放置标记以获取坐标,然后通过反向地理编码获取街道地址
安装
您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用程序中
composer require devops/nova-map-address
laravel 支持
此包支持 laravel v 7 和 8,较旧版本的 laravel https://github.com/JoseVte/nova-map-address
配置
发布包配置文件
php artisan vendor:publish --provider="devops\MapAddress\FieldServiceProvider"
这是将发布到 config/map-address.php 的文件内容。
将以下键添加到您的 .env
和 .env.example
MAP_ADDRESS_API_KEY=
Optional: Set map and address language
MAP_ADDRESS_LANGUAGE=es
如果您需要 Google Maps API 密钥,可以创建一个应用程序并启用 Places API,然后创建凭据以获取 API 密钥 https://console.developers.google.com。
用法
将以下内容添加到 Nova/{Model}.php 资源
use devops\MapAddress\MapAddress; [ MapAddress::make('address'), // You can set the initial map location. By default (Spain) MapAddress::make('address') ->initLocation(38.261842, -0.6868031), // You can set the location from the model MapAddress::make('address') ->setLocation($this->latitude, $this->longitude), // You can select the name of lat/lng fields. By default is lat/lng MapAddress::make('address') ->setLatitudeField('latitude') ->setLongitudeField('longitude'), // You can select what is the first result set in address field MapAddress::make('address') ->setGoogleResultType('street_address'), // You can also set the map zoom level. By default (4) MapAddress::make('address') ->initLocation(38.261842, -0.6868031) ->zoom(12), ]
信用
- Jose Vicente Orts: vince@square1.io
支持
- Jose Vicente Orts: vince@square1.io
许可
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。