2amigos / yii2-google-places-library
此包已被废弃,不再维护。未建议替换包。
Yii2 的 Google 地点 API 库。
1.0.3
2019-01-23 14:13 UTC
Requires
- 2amigos/google-places-library: ^1.0
- yiisoft/yii2: 2.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2023-08-09 19:50:26 UTC
README
扩展库,用于通过封装我们2amigos/google-places-library的方法与Google 地点 API进行交互,将其封装成 Yii2 组件。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require "2amigos/yii2-google-places-library" "*"
或者将以下内容添加到应用程序的 composer.json
文件中的 require 部分:
"2amigos/yii2-google-places-library" : "*"
That's it, you are ready to use them as Yii2 components.
安装
首选方式是将组件设置到我们应用程序的配置数组中
'components' => [ 'places' => [ 'class' => '\dosamigos\google\places\Places', 'key' => '{your-google-api-key-with-places-activated}', 'format' => 'json', // or 'xml' 'forceJsonArrayResponse' => true // for decoding responses to arrays instead of objects ], 'placesSearch' => [ 'class' => '\dosamigos\google\places\Search', 'key' => '{your-google-api-key-with-places-activated}', 'format' => 'json' // or 'xml' ] ]
That's it, you are ready to use them as Yii2 components.
使用搜索组件
// If you setup the format in 'json', the returned value will be an array. If 'xml', it will return a SimpleXmlElement. var_dump(Yii::$app->search->text('restaurants in Inca Mallorca'));
使用地点组件
var_dump(Yii::$app->place->details('{REFERENCEIDOFPLACE}'));
更多信息
有关 Google 地点的多个参数的更多信息,请访问其 API 参考以及我们的独立库2amigos/google-places-library
定制软件开发 | 网络和移动开发软件
www.2amigos.us