yii2mod / yii2-google-maps-markers
Google Maps Markers 在地图上显示一组用户地址作为标记。
1.4
2017-08-26 10:21 UTC
Requires
- yiisoft/yii2: *
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-20 21:49:33 UTC
README
Yii2的Google Maps Markers小部件
GoogleMaps小部件在地图上显示一组用户地址作为标记。
安装
安装此扩展的首选方式是通过 composer。
运行
php composer.phar require yii2mod/yii2-google-maps-markers "*"
或添加
"yii2mod/yii2-google-maps-markers": "*"
到您的composer.json文件的require部分。
使用方法
要使用GoogleMaps,您需要配置其 [[userLocations]] 属性。例如
echo yii2mod\google\maps\markers\GoogleMaps::widget([ 'userLocations' => [ [ 'location' => [ 'address' => 'Kharkiv', 'country' => 'Ukraine', ], 'htmlContent' => '<h1>Kharkiv</h1>', ], [ 'location' => [ 'city' => 'New York', 'country' => 'United States', ], 'htmlContent' => '<h1>New York</h1>', ], ], ]);
配置
要配置Google Maps密钥或其他选项,如语言、版本、库或地图选项
echo yii2mod\google\maps\markers\GoogleMaps::widget([ 'userLocations' => [...], 'googleMapsUrlOptions' => [ 'key' => 'this_is_my_key', 'language' => 'id', 'version' => '3.1.18', ], 'googleMapsOptions' => [ 'mapTypeId' => 'roadmap', 'tilt' => 45, 'zoom' => 5, ], ]);
或者通过yii params配置。例如
'params' => [ 'googleMapsUrlOptions' => [ 'key' => 'this_is_my_key', 'language' => 'id', 'version' => '3.1.18', ], 'googleMapsOptions' => [ 'mapTypeId' => 'roadmap', 'tilt' => 45, 'zoom' => 10, ], ],
获取密钥,请访问 页面
Google Maps选项
您可以在 选项页面 找到它们