@@ -82,8 +82,8 @@ |
||
82 | 82 | return "new ol.$this->class($properties)"; |
83 | 83 | } |
84 | 84 | |
85 | - public function __toString() { |
|
86 | - return $this->expression; |
|
87 | - } |
|
85 | + public function __toString() { |
|
86 | + return $this->expression; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -75,10 +75,11 @@ |
||
75 | 75 | */ |
76 | 76 | protected function generateExpression() |
77 | 77 | { |
78 | - if (isset($this->properties)) |
|
79 | - $properties = Json::encode($this->properties); |
|
80 | - else |
|
81 | - $properties = ''; |
|
78 | + if (isset($this->properties)) { |
|
79 | + $properties = Json::encode($this->properties); |
|
80 | + } else { |
|
81 | + $properties = ''; |
|
82 | + } |
|
82 | 83 | return "new ol.$this->class($properties)"; |
83 | 84 | } |
84 | 85 |
@@ -5,12 +5,12 @@ |
||
5 | 5 | |
6 | 6 | class OLModuleBundle extends AssetBundle |
7 | 7 | { |
8 | - public $sourcePath = __DIR__; |
|
8 | + public $sourcePath = __DIR__; |
|
9 | 9 | |
10 | - public $js = [ |
|
11 | - 'js/olwidget.js', |
|
12 | - ]; |
|
13 | - public $depends = [ |
|
14 | - 'yii\web\JqueryAsset', |
|
15 | - ]; |
|
10 | + public $js = [ |
|
11 | + 'js/olwidget.js', |
|
12 | + ]; |
|
13 | + public $depends = [ |
|
14 | + 'yii\web\JqueryAsset', |
|
15 | + ]; |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | class OpenLayers extends Widget |
15 | 15 | { |
16 | 16 | /** |
17 | - * @var array the HTML attributes for the container div of this widget. |
|
18 | - * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
|
19 | - */ |
|
17 | + * @var array the HTML attributes for the container div of this widget. |
|
18 | + * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
|
19 | + */ |
|
20 | 20 | public $options = []; |
21 | 21 | /** |
22 | 22 | * The properties to be passed to the OpenLayers Map() constructor. In order to ease passing complex JavaScript structures, some simplifications are supported. |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @var array |
25 | 25 | */ |
26 | 26 | public $mapOptions = []; |
27 | - /** |
|
28 | - * The scripts that operate with the olwidget.js module, e. g. to apply map configuration in plain JavaScript. |
|
29 | - * Can be array to register multiple scripts. If the array is given string keys, they will be passed to [[yii\web\View::registerJsFile()]]. |
|
30 | - * @var string|array |
|
31 | - */ |
|
32 | - public $mapOptionScript = []; |
|
27 | + /** |
|
28 | + * The scripts that operate with the olwidget.js module, e. g. to apply map configuration in plain JavaScript. |
|
29 | + * Can be array to register multiple scripts. If the array is given string keys, they will be passed to [[yii\web\View::registerJsFile()]]. |
|
30 | + * @var string|array |
|
31 | + */ |
|
32 | + public $mapOptionScript = []; |
|
33 | 33 | |
34 | 34 | public function init() |
35 | 35 | { |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | } |
39 | 39 | $this->mapOptions['target'] = $this->options['id']; |
40 | 40 | OpenLayersBundle::register($this->view); |
41 | - OLModuleBundle::register($this->view); |
|
41 | + OLModuleBundle::register($this->view); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function run() |
45 | 45 | { |
46 | 46 | $this->processMapOptions(); |
47 | 47 | |
48 | - $scripts = is_array($this->mapOptionScript) ? $this->mapOptionScript : [$this->mapOptionScript]; |
|
49 | - foreach ($scripts as $key => $script) { |
|
50 | - if (!is_string($key)) { |
|
51 | - $key = null; // Dont specify a key for non-associative array of scripts |
|
52 | - } |
|
53 | - $this->view->registerJsFile($script, ['depends'=>OLModuleBundle::className()], $key); |
|
54 | - } |
|
48 | + $scripts = is_array($this->mapOptionScript) ? $this->mapOptionScript : [$this->mapOptionScript]; |
|
49 | + foreach ($scripts as $key => $script) { |
|
50 | + if (!is_string($key)) { |
|
51 | + $key = null; // Dont specify a key for non-associative array of scripts |
|
52 | + } |
|
53 | + $this->view->registerJsFile($script, ['depends'=>OLModuleBundle::className()], $key); |
|
54 | + } |
|
55 | 55 | |
56 | - $script = 'sibilino.olwidget.createMap('.Json::encode($this->mapOptions).', "'.$this->options['id'].'")'; |
|
56 | + $script = 'sibilino.olwidget.createMap('.Json::encode($this->mapOptions).', "'.$this->options['id'].'")'; |
|
57 | 57 | $this->view->registerJs($script); |
58 | 58 | |
59 | 59 | return Html::tag('div', '', $this->options); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | foreach ($this->mapOptions['layers'] as $type => $options) { |
98 | 98 | if (is_string($type)) { |
99 | 99 | if (is_string($options)) { |
100 | - $options = ['source' => new OL("source.$options")]; |
|
101 | - } |
|
100 | + $options = ['source' => new OL("source.$options")]; |
|
101 | + } |
|
102 | 102 | $processedLayers []= new OL("layer.$type", $options); |
103 | 103 | } else { // Therefore $type is simply an integer array key |
104 | - $processedLayers []= $options; |
|
105 | - } |
|
104 | + $processedLayers []= $options; |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | $this->mapOptions['layers'] = $processedLayers; |
108 | 108 | } |
@@ -99,9 +99,9 @@ |
||
99 | 99 | if (is_string($options)) { |
100 | 100 | $options = ['source' => new OL("source.$options")]; |
101 | 101 | } |
102 | - $processedLayers []= new OL("layer.$type", $options); |
|
102 | + $processedLayers [] = new OL("layer.$type", $options); |
|
103 | 103 | } else { // Therefore $type is simply an integer array key |
104 | - $processedLayers []= $options; |
|
104 | + $processedLayers [] = $options; |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | $this->mapOptions['layers'] = $processedLayers; |