1 | <?php |
||
3 | class MapUtil |
||
4 | { |
||
5 | |||
6 | /** |
||
7 | * @var string The Google Maps API key |
||
8 | */ |
||
9 | protected static $api_key; |
||
10 | |||
11 | /** |
||
12 | * @var int Number of active {@see GoogleMapsAPI} instances (for the HTML ID) |
||
13 | */ |
||
14 | protected static $instances = 0; |
||
15 | |||
16 | /** |
||
17 | * @var int The default width of a Google Map |
||
18 | */ |
||
19 | public static $map_width = '100%'; |
||
20 | |||
21 | /** |
||
22 | * @var int The default height of a Google Map |
||
23 | */ |
||
24 | public static $map_height = '400px'; |
||
25 | |||
26 | /** @var int Icon width of the gmarker **/ |
||
27 | public static $iconWidth = 24; |
||
28 | |||
29 | /** @var int Icon height of the gmarker **/ |
||
30 | public static $iconHeight = 24; |
||
31 | |||
32 | /** |
||
33 | * @var int Prefix for the div ID of the map |
||
34 | */ |
||
35 | public static $div_id = "google_map"; |
||
36 | |||
37 | /** |
||
38 | * @var boolean Automatic center/zoom for the map |
||
39 | */ |
||
40 | public static $automatic_center = true; |
||
41 | |||
42 | /** |
||
43 | * @var boolean Show directions fields on the map |
||
44 | */ |
||
45 | public static $direction_fields = false; |
||
46 | |||
47 | /** |
||
48 | * @var boolean Show the marker fields on the map |
||
49 | */ |
||
50 | public static $hide_marker = false; |
||
51 | |||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * @var boolean Show the marker fields on the map |
||
57 | */ |
||
58 | public static $map_type = 'google.maps.MapTypeId.ROADMAP'; |
||
59 | |||
60 | /** |
||
61 | * @var string $center Center of map (adress) |
||
62 | */ |
||
63 | public static $center = 'Paris, France'; |
||
64 | |||
65 | /* Width of the map information window */ |
||
66 | public static $info_window_width = 250; |
||
67 | |||
68 | /* Signals whether at least one map has already been rendered */ |
||
69 | private static $map_already_rendered = false; |
||
70 | |||
71 | /* Whether or not to allow full screen */ |
||
72 | private static $allow_full_screen = null; |
||
73 | |||
74 | |||
75 | public static function reset() { |
||
92 | |||
93 | /** |
||
94 | * Set the API key for Google Maps |
||
95 | * |
||
96 | * @param string $key |
||
97 | */ |
||
98 | public static function set_api_key($key) { |
||
101 | |||
102 | |||
103 | /** |
||
104 | * @param boolean $new_map_already_rendered |
||
105 | */ |
||
106 | public static function set_map_already_rendered($new_map_already_rendered) { |
||
109 | |||
110 | public static function get_map_already_rendered() { |
||
113 | |||
114 | /** |
||
115 | * Set the default size of the map |
||
116 | * |
||
117 | * @param int $width |
||
118 | * @param int $height |
||
119 | */ |
||
120 | public static function set_map_size($width, $height) { |
||
124 | |||
125 | /** |
||
126 | * FIXME - NOT USED? |
||
127 | * Set the type of the gmap |
||
128 | * |
||
129 | * @param string $mapType (can be 'google.maps.MapTypeId.ROADMAP', 'G_SATELLITE_MAP', |
||
130 | * 'G_HYBRID_MAP', 'G_PHYSICAL_MAP') |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | public static function set_map_type($mapType) { |
||
137 | |||
138 | /** |
||
139 | * FIXME - NOT USED? |
||
140 | * Set the with of the gmap infowindow (on marker clik) |
||
141 | * |
||
142 | * @param int $info_window_width GoogleMap info window width |
||
143 | * |
||
144 | * @return void |
||
145 | */ |
||
146 | public static function set_info_window_width($info_window_width) |
||
150 | |||
151 | /** |
||
152 | * FIXME - NOT USED? |
||
153 | * Set the center of the gmap (an address) |
||
154 | * |
||
155 | * @param string $center GoogleMap center (an address) |
||
156 | * |
||
157 | * @return void |
||
158 | */ |
||
159 | public static function set_center($center) |
||
163 | |||
164 | /** |
||
165 | * FIXME Is this used? |
||
166 | * |
||
167 | * Set the size of the icon markers |
||
168 | * |
||
169 | * @param int $iconWidth GoogleMap marker icon width |
||
170 | * @param int $iconHeight GoogleMap marker icon height |
||
171 | * |
||
172 | * @return void |
||
173 | */ |
||
174 | |||
175 | public static function set_icon_size($iconWidth, $iconHeight) |
||
180 | |||
181 | /** |
||
182 | * Get a new GoogleMapAPI object and load it with the default settings |
||
183 | * |
||
184 | * @return MapAPI |
||
185 | */ |
||
186 | public static function instance() |
||
223 | |||
224 | |||
225 | /** |
||
226 | * Sanitize a string of HTML content for safe inclusion in the JavaScript |
||
227 | * for a Google Map |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | public static function sanitize($content) { |
||
234 | |||
235 | |||
236 | /** |
||
237 | * Creates a new {@link GoogleMapsAPI} object loaded with the default settings |
||
238 | * and places all of the items in a {@link SS_List} |
||
239 | * e.g. {@link DataList} or {@link ArrayList} on the map |
||
240 | * |
||
241 | * @param SS_List list of objects to display on a map |
||
242 | * @param array $infowindowtemplateparams Optional array of extra parameters to pass to the map info window |
||
243 | * @return MapAPI |
||
244 | */ |
||
245 | public static function get_map(SS_List $list, $infowindowtemplateparams) { |
||
255 | |||
256 | /** |
||
257 | * Determines if the current DataObject should be included to the map |
||
258 | * Checks if it has Mappable interface implemented |
||
259 | * If it has MapExtension included, the value of MapPinEdited is also checked |
||
260 | * |
||
261 | * @param DataObject $do |
||
262 | * @return bool |
||
263 | */ |
||
264 | private static function ChooseToAddDataobject(DataObject $do) { |
||
277 | } |
||
278 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.