-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleGoogleMaps.php
82 lines (69 loc) · 2.1 KB
/
SimpleGoogleMaps.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* This file contains QUI\Bricks\Controls\SimpleGoogleMaps
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class SimpleGoogleMaps
*
* @package quiqqer/bricks
*/
class SimpleGoogleMaps extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'title' => '',
'preventLoadMap' => false
]);
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/SimpleGoogleMaps.css'
);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$brickPlace = $this->getAttribute('place');
$brickZip = $this->getAttribute('zip');
$brickStreet = $this->getAttribute('street');
$brickCity = $this->getAttribute('city');
$zoom = $this->getAttribute('zoom');
$preventLoadMap = $this->getAttribute('preventLoadMap');
$imgUrl = '';
if (!$zoom) {
$zoom = 15;
}
$query = http_build_query([
'key' => trim($this->getAttribute('api')),
'q' => "{$brickPlace},{$brickZip},{$brickStreet},{$brickCity}"
]);
$url = 'https://www.google.com/maps/embed/v1/place?' . $query . "&zoom=" . $zoom;
if ($preventLoadMap) {
$imgUrl = URL_OPT_DIR . 'quiqqer/bricks/bin/images/SimpleGoogleMapsBackground1.png';
$this->setAttributes([
'qui-class' => "package/quiqqer/bricks/bin/Controls/SimpleGoogleMaps",
'data-qui-url' => $url,
'data-qui-imgUrl' => $imgUrl
]);
}
$Engine->assign([
'this' => $this,
'url' => $url,
'preventLoadMap' => $preventLoadMap
]);
return $Engine->fetch(dirname(__FILE__) . '/SimpleGoogleMaps.html');
}
}