wedevelopnl/silverstripe-addressfield
最新稳定版本:1.0.13
Composer 安装命令:
composer require wedevelopnl/silverstripe-addressfield
包简介
Silverstripe module to create nested menus
README 文档
README
Introduction
Address field with geolocation
Requirements
- Silverstripe CMS
^4 || ^5 - "jeroendesloovere/geolocation-php-api": "1.3.*"
Installation
composer require "thewebmen/silverstripe-addressfield" "dev-master"
Config
Add the Google Maps API key:
TheWebmen\Addressfield\Forms\GooglePlacesField: maps_api_key: 'API_KEY'
Or add the following variable to your .env:
WDVLP_ADDRESSFIELD_MAPS_API_KEY='API_KEY'
Usage
Add all db fields to the db array:
private static $db = [
'City' => 'Varchar',
'Country' => 'Varchar',
'ZipCode' => 'Varchar',
'Street' => 'Varchar',
'StreetNumber' => 'Varchar',
'Latitude' => 'Varchar',
'Longitude' => 'Varchar'
];
Then add the field like any other field
public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Address', new AddressField($this->owner)); }
See the addressfield class for all constructor options.
Distance helper
The module comes with a distance helper to calculate the distance between two latitude/longitudes, example usage:
$list = ObjectWithLatitudeLongitude::get(); $list = TheWebmen\Addressfield\Helpers\DistanceHelper::addDistance($list, '52.2112', '5.9699'); $list = $list->sort('Distance'); foreach($list as $item){ var_dump($item->Distance); }
Todo
- Improve documentation
统计信息
- 总下载量: 91
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2024-01-29