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 the marker fields on the map |
||
44 | */ |
||
45 | public static $hide_marker = false; |
||
46 | |||
47 | |||
48 | |||
49 | |||
50 | /** |
||
51 | * @var boolean Show the marker fields on the map |
||
52 | */ |
||
53 | public static $map_type = 'google.maps.MapTypeId.ROADMAP'; |
||
54 | |||
55 | /** |
||
56 | * @var string $center Center of map (adress) |
||
57 | */ |
||
58 | public static $center = 'Paris, France'; |
||
59 | |||
60 | /* Width of the map information window */ |
||
61 | public static $info_window_width = 250; |
||
62 | |||
63 | /* Whether or not to allow full screen */ |
||
64 | private static $allow_full_screen = null; |
||
65 | |||
66 | |||
67 | public static function reset() { |
||
82 | |||
83 | /** |
||
84 | * Set the API key for Google Maps |
||
85 | * |
||
86 | * @param string $key |
||
87 | */ |
||
88 | public static function set_api_key($key) { |
||
91 | |||
92 | /** |
||
93 | * Set the default size of the map |
||
94 | * |
||
95 | * @param int $width |
||
96 | * @param int $height |
||
97 | */ |
||
98 | public static function set_map_size($width, $height) { |
||
102 | |||
103 | /** |
||
104 | * FIXME - NOT USED? |
||
105 | * Set the type of the gmap |
||
106 | * |
||
107 | * @param string $mapType (can be 'google.maps.MapTypeId.ROADMAP', 'G_SATELLITE_MAP', |
||
108 | * 'G_HYBRID_MAP', 'G_PHYSICAL_MAP') |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | public static function set_map_type($mapType) { |
||
115 | |||
116 | /** |
||
117 | * FIXME - NOT USED? |
||
118 | * Set the with of the gmap infowindow (on marker clik) |
||
119 | * |
||
120 | * @param int $info_window_width GoogleMap info window width |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public static function set_info_window_width($info_window_width) |
||
128 | |||
129 | /** |
||
130 | * FIXME - NOT USED? |
||
131 | * Set the center of the gmap (an address) |
||
132 | * |
||
133 | * @param string $center GoogleMap center (an address) |
||
134 | * |
||
135 | * @return void |
||
136 | */ |
||
137 | public static function set_center($center) |
||
141 | |||
142 | /** |
||
143 | * FIXME Is this used? |
||
144 | * |
||
145 | * Set the size of the icon markers |
||
146 | * |
||
147 | * @param int $iconWidth GoogleMap marker icon width |
||
148 | * @param int $iconHeight GoogleMap marker icon height |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | |||
153 | public static function set_icon_size($iconWidth, $iconHeight) |
||
158 | |||
159 | /** |
||
160 | * Get a new GoogleMapAPI object and load it with the default settings |
||
161 | * |
||
162 | * @return MapAPI |
||
163 | */ |
||
164 | public static function instance() |
||
199 | |||
200 | |||
201 | /** |
||
202 | * Sanitize a string of HTML content for safe inclusion in the JavaScript |
||
203 | * for a Google Map |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | public static function sanitize($content) { |
||
210 | |||
211 | |||
212 | /** |
||
213 | * Creates a new {@link GoogleMapsAPI} object loaded with the default settings |
||
214 | * and places all of the items in a {@link SS_List} |
||
215 | * e.g. {@link DataList} or {@link ArrayList} on the map |
||
216 | * |
||
217 | * @param SS_List list of objects to display on a map |
||
218 | * @param array $infowindowtemplateparams Optional array of extra parameters to pass to the map info window |
||
219 | * @return MapAPI |
||
220 | */ |
||
221 | public static function get_map(SS_List $list, $infowindowtemplateparams) { |
||
231 | |||
232 | /** |
||
233 | * Determines if the current DataObject should be included to the map |
||
234 | * Checks if it has Mappable interface implemented |
||
235 | * If it has MapExtension included, the value of MapPinEdited is also checked |
||
236 | * |
||
237 | * @param DataObject $do |
||
238 | * @return bool |
||
239 | */ |
||
240 | private static function ChooseToAddDataobject(DataObject $do) { |
||
253 | } |
||
254 |
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.