1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2015 Petr Olišar (http://olisar.eu) |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view |
6
|
|
|
* the file LICENSE.md that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Oli\GoogleAPI; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Description of MapApiExtension |
14
|
|
|
* |
15
|
|
|
* @author Petr Olišar <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class MapApiExtension extends \Nette\DI\CompilerExtension |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
public $defaults = array( |
21
|
|
|
'key' => null, |
22
|
|
|
'width' => '100%', |
23
|
|
|
'height' => '100%', |
24
|
|
|
'zoom' => 7, |
25
|
|
|
'coordinates' => array(), |
26
|
|
|
'type' => 'ROADMAP', |
27
|
|
|
'scrollable' => true, |
28
|
|
|
'static' => false, |
29
|
|
|
'markers' => array( |
30
|
|
|
'bound' => false, |
31
|
|
|
'markerClusterer' => false, |
32
|
|
|
'iconDefaultPath' => null, |
33
|
|
|
'icon' => null, |
34
|
|
|
'addMarkers' => array() |
35
|
|
|
) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function loadConfiguration() |
40
|
|
|
{ |
41
|
|
|
$config = $this->getConfig($this->defaults); |
42
|
|
|
$builder = $this->getContainerBuilder(); |
43
|
|
|
|
44
|
|
|
$builder->addDefinition($this->prefix('mapAPI')) |
45
|
|
|
->setImplement('Oli\GoogleAPI\IMapAPI') |
46
|
|
|
->setFactory('Oli\GoogleAPI\MapAPI') |
47
|
|
|
->addSetup('setup', array($config)) |
48
|
|
|
->addSetup('setKey', array($config['key'])) |
49
|
|
|
->addSetup('setCoordinates', array($config['coordinates'])) |
50
|
|
|
->addSetup('setType', array($config['type'])) |
51
|
|
|
->addSetup('isStaticMap', array($config['static'])) |
52
|
|
|
->addSetup('isScrollable', array($config['scrollable'])) |
53
|
|
|
->addSetup('setZoom', array($config['zoom'])); |
54
|
|
|
|
55
|
|
|
$builder->addDefinition($this->prefix('markers')) |
56
|
|
|
->setImplement('Oli\GoogleAPI\IMarkers') |
57
|
|
|
->setFactory('Oli\GoogleAPI\Markers') |
58
|
|
|
->addSetup('setDefaultIconPath', array($config['markers']['iconDefaultPath'])) |
59
|
|
|
->addSetup('fitBounds', array($config['markers']['bound'])) |
60
|
|
|
->addSetup('isMarkerClusterer', array($config['markers']['markerClusterer'])) |
61
|
|
|
->addSetup('addMarkers', array($config['markers']['addMarkers'])); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|