-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathGoogleMaps_StaticMapModel.php
55 lines (48 loc) · 1.44 KB
/
GoogleMaps_StaticMapModel.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
<?php
namespace Craft;
class GoogleMaps_StaticMapModel extends BaseModel
{
public function getParameters()
{
$params = array();
foreach($this->getAttributes() as $attr => $value)
{
if(!is_array($value) && $value)
{
$params[] = $attr.'='.$value;
}
else if(is_array($value))
{
foreach($value as $obj)
{
$params[] = str_replace('#', '%23', $obj->getStaticMapParameters());
}
}
}
return implode('&', $params);
}
public static function populateModel($data)
{
$model = parent::populateModel($data);
if(isset($data['width']) && $data['height'])
{
$model->size = $data['width'].'x'.$data['height'];
}
return $model;
}
protected function defineAttributes()
{
return array(
// Location Parameters
'format' => array(AttributeType::String, 'default' => 'png'),
'center' => array(AttributeType::Mixed, 'default' => false),
'maptype' => array(AttributeType::Mixed, 'default' => false),
'markers' => array(AttributeType::Mixed, 'default' => array()),
'paths' => array(AttributeType::Mixed, 'default' => array()),
'scale' => array(AttributeType::Number, 'default' => 1),
'style' => array(AttributeType::Mixed, 'default' => false),
'size' => array(AttributeType::Mixed, 'default' => '400x300'),
'zoom' => array(AttributeType::Mixed, 'default' => false),
);
}
}