katzz0 / yii2-yandex-maps
Yii 2 Yandex 地图模块
dev-master
2015-07-02 11:19 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
This package is not auto-updated.
Last update: 2024-09-24 03:44:03 UTC
README
此仓库是从 yii2-yandex-maps 的 Mirocow 分支而来
组件
katzz0\yandexmaps\Api
katzz0\yandexmaps\Map
katzz0\yandexmaps\Canvas
katzz0\yandexmaps\JavaScript
katzz0\yandexmaps\Placemark
katzz0\yandexmaps\Polyline
- 待办事项:Geo XML
- 待办事项:GeoObject
- 待办事项:Balloon
- 待办事项:Hint
- 待办事项:Clusterer
katzz0\yandexmaps\Api
注册脚本的应用程序组件。
用法
将组件附加到应用程序(例如,编辑config/main.php)
'components' => [ 'yandexMapsApi' => [ 'class' => 'mirocow\yandexmaps\Api', ] ],
katzz0\yandexmaps\Map
地图实例。
用法
use katzz0\yandexmaps\Map; $map = new Map('yandex_map', [ 'center' => [55.7372, 37.6066], 'zoom' => 10, // Enable zoom with mouse scroll 'behaviors' => array('default', 'scrollZoom'), 'type' => "yandex#map", ], [ // Permit zoom only fro 9 to 11 'minZoom' => 9, 'maxZoom' => 11, 'controls' => [ "new ymaps.control.SmallZoomControl()", "new ymaps.control.TypeSelector(['yandex#map', 'yandex#satellite'])", ], ] );
katzz0\yandexmaps\Canvas
这是一个渲染您地图 HTML 标签的部件。
用法
简单地将部件添加到视图
use katzz0\yandexmaps\Canvas as YandexMaps; <?= YandexMaps::widget([ 'htmlOptions' => [ 'style' => 'height: 600px;', ], 'map' => new Map('yandex_map', [ 'center' => [55.7372, 37.6066], 'zoom' => 17, 'controls' => [Map::CONTROL_ZOOM], 'behaviors' => [Map::BEHAVIOR_DRAG], 'type' => "yandex#map", ], [ 'objects' => [new Placemark(new Point(55.7372, 37.6066), [], [ 'draggable' => true, 'preset' => 'islands#dotIcon', 'iconColor' => '#2E9BB9', 'events' => [ 'dragend' => 'js:function (e) { console.log(e.get(\'target\').geometry.getCoordinates()); }' ] ])] ]) ]) ?>
您还可以使用直接放置标签
<?= YandexMaps::widget([ 'htmlOptions' => [ 'style' => 'height: 600px;', ], 'map' => new Map(null, [ 'center' => 'London', 'zoom' => 17, 'controls' => [Map::CONTROL_ZOOM], 'behaviors' => [Map::BEHAVIOR_DRAG], 'type' => "yandex#map", ], [ 'objects' => [new Placemark(null, [], [ 'draggable' => true, 'preset' => 'islands#dotIcon', 'iconColor' => '#2E9BB9', 'events' => [ 'dragend' => 'js:function (e) { console.log(e.get(\'target\').geometry.getCoordinates()); }' ] ])] ]) ]) ?>