This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
EGMapDirectionRenderer.php
123 lines (114 loc) · 5 KB
/
EGMapDirectionRenderer.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* EGMapDirectionRenderer class
*
* @author Antonio Ramirez
* @since 2010-12-24
* @link http://www.ramirezcobos.com
*
*
* @copyright
*
* Copyright (c) 2010 Antonio Ramirez Cobos
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
class EGMapDirectionRenderer extends EGMapBase
{
protected $options = array(
// If true, allows the user to drag and modify the paths of
// routes rendered by this DirectionsRenderer.
'draggable' => false,
// This property indicates whether the renderer should provide
// UI to select amongst alternative routes. By default, this flag
// is false and a user-selectable list of routes will be shown in
// the directions' associated panel. To hide that list, set
// hideRouteList to true.
'hideRouteList' => null,
// The InfoWindow in which to render text information when a marker
// is clicked. Existing info window content will be overwritten and
// its position moved. If no info window is specified, the DirectionsRenderer
// will create and use its own info window. This property will be ignored
// if suppressInfoWindows is set to true.
'infoWindow' => null,
// Map on which to display the directions.
// Will be overriden when enabled to a EGMapDirection
'map' => null,
// review marker options
'markerOptions'=>null,
// The element (node getElementById().)
'panel' => null,
// Options for the polylines. All polylines rendered by the DirectionsRenderer
// will use these options.
// Full reference on http://code.google.com/intl/en-EN/apis/maps/documentation/javascript/reference.html#PolylineOptions
'polylineOptions' =>
array(
'clickable'=>null,
'strokeColor'=>null,
'strokeOpacity'=>null,
'strokeWeight'=>null,
'zIndex'=>null),
// By default, the input map is centered and zoomed to the bounding box of
// this set of directions. If this option is set to true, the viewport is left
//unchanged, unless the map's center and zoom were never set.
'preserveViewPort' => null,
// The index of the route within the DirectionsResult object. The default value is 0.
'routeIndex'=>null,
// Suppress the rendering of the BicyclingLayer when bicycling directions are requested.
'suppressBicyclingLayer' => null,
// Suppress the rendering of the BicyclingLayer when bicycling directions are requested.
'suppressInfoWindows' => null,
// Suppress the rendering of markers.
'suppressMarkers' => null,
// Suppress the rendering of polylines
'suppressPolylines' => null
);
/**
* Construct GMapDirectionRenderer object
*
* @param string $js_name The js var name
* @param array $options Array of options
* @author Antonio Ramirez
* @since 2011-01-24
*/
public function __construct( $js_name = 'gmap_direction', $options = array())
{
$this->setOptions($options);
if( $js_name !=='gmap_direction' )
$this->setJsName($js_name);
}
public function setOptions( $options ){
if(isset($options['polylineOptions'])){
$this->setPolylineOptions($options['polylineOptions']);
unset($options['polylineOptions']);
}
$this->options = array_merge( $this->options, $options );
}
public function setPolylineOptions( $value )
{
if(!is_array($value))
{
throw new CException(Yii::t('EGMap','Property "{class}.{property}" must be of type array.',
array('{class}'=>get_class($this), '{property}'=>'polylineOptions')));
}
$this->options['polylineOptions'] = array_merge($this->options['polylineOptions'],$value);
}
public function toJs(){
if( null !== $this->panel )
$this->panel = "document.getElementById('".$this->panel."')";
if(count($this->options['polylineOptions'])) $this->options['polylineOptions'] = CJavaScript::encode($this->options['polylineOptions']);
return 'var '.$this->getJsName().' = new google.maps.DirectionsRenderer('.EGMap::encode($this->options).');'."\n";
}
}