-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMapInputWidget.php
66 lines (46 loc) · 1.51 KB
/
MapInputWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace kolyunya\yii2\widgets;
use Yii;
class MapInputWidget extends \yii\widgets\InputWidget
{
public $key;
public $latitude = 0;
public $longitude = 0;
public $zoom = 0;
public $width = '100%';
public $height = '300px';
public $pattern = '(%latitude%,%longitude%)';
public $mapType = 'roadmap';
public $animateMarker = false;
public $alignMapCenter = true;
public $enableSearchBar = true;
public $viewFile = 'MapInputWidget';
public function run()
{
Yii::setAlias('@kolyunya','@vendor/kolyunya');
// Asset bundle should be configured with the application key
$this->configureAssetBundle();
return $this->render(
$this->viewFile,
[
'id' => $this->getId(),
'model' => $this->model,
'attribute' => $this->attribute,
'latitude' => $this->latitude,
'longitude' => $this->longitude,
'zoom' => $this->zoom,
'width' => $this->width,
'height' => $this->height,
'pattern' => $this->pattern,
'mapType' => $this->mapType,
'animateMarker' => $this->animateMarker,
'alignMapCenter' => $this->alignMapCenter,
'enableSearchBar' => $this->enableSearchBar,
]
);
}
private function configureAssetBundle()
{
\kolyunya\yii2\assets\MapInputAsset::$key = $this->key;
}
}