jfeid/nova-google-maps
最新稳定版本:v1.1
Composer 安装命令:
composer require jfeid/nova-google-maps
包简介
A Laravel Nova field using Google Maps to provide latitude/longitude data.
README 文档
README
A Laravel Nova field that uses Google Maps to update latitude/longitude model fields.
Requirements
Package supports Nova 2.x (Laravel 5.8.x), Vue 2.6.x
Installation
Install the package in to a Laravel app that uses Nova via composer:
composer require jfeid/nova-google-maps
Publish the package configuration to your Laravel config directory:
php artisan vendor:publish --provider="Jfeid\NovaGoogleMaps\FieldServiceProvider" --tag="config"
You need to type your Google Map API key in the .env file as follows:
GMAPS_API_KEY=YOUR_API_KEY_HERE
Optionally, you can adjust the following configuration options in the .env file:
# Default latitude value when empty GMAPS_DEFAULT_LATITUDE= # Default longitude value when empty GMAPS_DEFAULT_LONGITUDE= # Default map zoom value GMAPS_DEFAULT_ZOOM=9
Usage
Add the following to a Nova resource:
NovaGoogleMaps::make('Location')->setValue($this->location_lat, $this->location_lng)
The field requires to initialize its value using the setValue method by passing your model's lat/lng fields as parameters.
Also the field requires to know your names of the model's lat/lng fields in order to use them in POST requests.
By default, the field will use the base attribute ('location' in this example) suffixed with _lat and _lng.
For example:
// POST data ... location_lat=40.2711861 location_lng=22.4755078 ...
If the default naming does not work for you, you can explicitly set the attribute names for lat/lng as follows:
NovaGoogleMaps::make('Location')->setAttributes('my_latitude', 'my_longitude')
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 7.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-04