firesphere / googlemapsfield
Google 地点 API 字段用于 SilverStripe
Requires
- silverstripe/framework: ^4.0|^5.0
- silverstripe/siteconfig: ^4.0|^5.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^9
This package is auto-updated.
Last update: 2023-10-15 23:59:19 UTC
README
Google 地点字段
在 SilverStripe 的表单中玩转 Google 地点
安装
composer require firesphere/googlemapsfield
使用
将表单字段添加到表单中,并在 SiteConfig 中输入您的密钥。
来自 Google 地点的所有信息将自动填充到隐藏字段中。您需要在保存表单时将这些映射到您自己的 DataObject 存储上。
提供的字段包括:
- GoogleMapsLatField
- GoogleMapsLngField
- subpremise
- street_number
- route
- sublocality_level_1
- locality
- administrative_area_level_1
- country
- postal_code
如果您想更改字段,添加自定义隐藏字段或删除某些字段,您可以通过 getExtraFields
和 setExtraFields
方法实现。
由于字段 ID 的限制,此字段在每个表单中只能使用一次。
自定义选项
https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete
您想添加的任何选项都可以作为数组设置在字段上
$field = GoogleMapsField::create('MyField'); $field->setCustomOptions(['componentRestrictions' => ['country' => 'nz']]);
实际许可
此模块在 BSD 3-clause 许可下发布,尽管这些许可实际上不在类中,但许可仍然适用
https://open-source.org.cn/licenses/BSD-3-Clause
版权 (c) 2012-NOW(), Simon "Firesphere" Erkelens
保留所有权利。
重新分发和使用源代码和二进制代码,无论是否修改,只要满足以下条件
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
本软件由版权所有者和贡献者提供“按原样”以及任何明示或暗示的保证,包括但不限于,适销性和特定用途的适用性保证,均予以放弃。在任何情况下,版权所有者或贡献者不应对任何直接、间接、偶然、特殊、示范性或后果性的损害(包括但不限于,替代商品或服务的采购;使用、数据或利润的损失;或业务中断)承担责任,无论此类损害是否因本软件的使用或本软件的使用可能性而引起,即使已被告知此类损害的可能性。
您是否阅读了整个 README?您太棒了!
下面有一头牛,就为了您。
/( ,,,,, )\
_\,;;;;;;;,/_
.-"; ;;;;;;;;; ;"-.
'.__/`_ / \ _`\__.'
| (')| |(') |
| .--' '--. |
|/ o o \|
| |
/ \ _..=.._ / \
/:. '._____.' \
;::' / \ .;
| _|_ _|_ ::|
.-| '==o==' '|-.
/ | . / \ | \
| | ::| | | .|
| ( ') (. )::|
|: | |; U U ;|:: | `|
|' | | \ U U / |' | |
##V| |_/`"""`\_| |V##
##V## ##V##