Index: trunk/extensions/GoogleMaps/export/GoogleMapsJsExporter.php |
— | — | @@ -1,279 +1,279 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class GoogleMapsJsExporter extends GoogleMapsExporter { |
5 | | - var $mEnablePaths; |
6 | | - var $mLanguage; |
7 | | - var $mProxyKey; |
| 5 | + var $mEnablePaths; |
| 6 | + var $mLanguage; |
| 7 | + var $mProxyKey; |
8 | 8 | |
9 | | - function __construct(&$pLanguage, &$pProxyKey, $pEnablePaths = true) { |
10 | | - $this->mOutput = ''; |
11 | | - $this->mLanguage =& $pLanguage; |
12 | | - $this->mProxyKey =& $pProxyKey; |
13 | | - $this->mEnablePaths = $pEnablePaths; |
14 | | - } |
| 9 | + function __construct(&$pLanguage, &$pProxyKey, $pEnablePaths = true) { |
| 10 | + $this->mOutput = ''; |
| 11 | + $this->mLanguage =& $pLanguage; |
| 12 | + $this->mProxyKey =& $pProxyKey; |
| 13 | + $this->mEnablePaths = $pEnablePaths; |
| 14 | + } |
15 | 15 | |
16 | | - function addXmlSource($url) { |
17 | | - $url = addslashes($url); |
18 | | - $this->mOutput .= <<<JAVASCRIPT |
19 | | - map.addOverlay(new GGeoXml("{$url}".replace(/&/g, "&".charAt(0)))); /* HACK HACK HACK */ |
| 16 | + function addXmlSource($url) { |
| 17 | + $url = addslashes($url); |
| 18 | + $this->mOutput .= <<<JAVASCRIPT |
| 19 | + map.addOverlay(new GGeoXml("{$url}".replace(/&/g, "&".charAt(0)))); /* HACK HACK HACK */ |
20 | 20 | JAVASCRIPT; |
21 | | - } |
| 21 | + } |
22 | 22 | |
23 | | - /** |
24 | | - * Adds a polyline or polygon to the google map. |
25 | | - * |
26 | | - * @param $pPolyline [string] - an array of lat/lon associative arrays |
27 | | - * @param $pColor string - the hex code for the color of the polyline |
28 | | - * @param $pStroke integer - the thickness, in pixels, of the polyline |
29 | | - * @param $pFillColor string - the hex code for the fill color (optional) |
30 | | - * |
31 | | - * @return string - the javascript string for adding the polyline to the map |
32 | | - **/ |
33 | | - function addPolyline ( $pPolyline, $pLineColor, $pLineOpacity, $pStroke, $pFillColor, $pFillOpacity ) |
34 | | - { |
35 | | - // get a hex code and transparency for the color |
36 | | - if (count($pPolyline) == 0) { |
37 | | - return; |
38 | | - } |
39 | | - if (!$this->mEnablePaths) { |
40 | | - return; |
41 | | - } |
42 | | - $polyline = array(); |
43 | | - foreach ($pPolyline as $p) { |
44 | | - $polyline[] = "new GLatLng({$p['lat']}, {$p['lon']})"; |
45 | | - } |
46 | | - $lineOpacity = GoogleMaps::hex2fraction( $pLineOpacity ); |
| 23 | + /** |
| 24 | + * Adds a polyline or polygon to the google map. |
| 25 | + * |
| 26 | + * @param $pPolyline [string] - an array of lat/lon associative arrays |
| 27 | + * @param $pColor string - the hex code for the color of the polyline |
| 28 | + * @param $pStroke integer - the thickness, in pixels, of the polyline |
| 29 | + * @param $pFillColor string - the hex code for the fill color (optional) |
| 30 | + * |
| 31 | + * @return string - the javascript string for adding the polyline to the map |
| 32 | + **/ |
| 33 | + function addPolyline ( $pPolyline, $pLineColor, $pLineOpacity, $pStroke, $pFillColor, $pFillOpacity ) |
| 34 | + { |
| 35 | + // get a hex code and transparency for the color |
| 36 | + if (count($pPolyline) == 0) { |
| 37 | + return; |
| 38 | + } |
| 39 | + if (!$this->mEnablePaths) { |
| 40 | + return; |
| 41 | + } |
| 42 | + $polyline = array(); |
| 43 | + foreach ($pPolyline as $p) { |
| 44 | + $polyline[] = "new GLatLng({$p['lat']}, {$p['lon']})"; |
| 45 | + } |
| 46 | + $lineOpacity = GoogleMaps::hex2fraction( $pLineOpacity ); |
47 | 47 | |
48 | | - if ( isset( $pFillColor ) ) { |
49 | | - $fillOpacity = GoogleMaps::hex2fraction( $pFillOpacity ); |
50 | | - $polyline[] = $polyline[0]; |
51 | | - $this->mOutput .= " map.addOverlay(new GPolygon( [ " . implode( ", ", $polyline )." ], ". |
52 | | - "'#{$pLineColor}', {$pStroke} , {$lineOpacity}, ". |
53 | | - "'#{$pFillColor}', {$fillOpacity}, {'clickable': false})); "; |
54 | | - } else { |
55 | | - // build the javascript for adding the polyline |
56 | | - $this->mOutput .= " map.addOverlay(new GPolyline( [ " . implode( ", ", $polyline )." ], ". |
57 | | - "'#{$pLineColor}', {$pStroke}, {$lineOpacity}, {'clickable': false})); "; |
58 | | - } |
59 | | - } |
| 48 | + if ( isset( $pFillColor ) ) { |
| 49 | + $fillOpacity = GoogleMaps::hex2fraction( $pFillOpacity ); |
| 50 | + $polyline[] = $polyline[0]; |
| 51 | + $this->mOutput .= " map.addOverlay(new GPolygon( [ " . implode( ", ", $polyline )." ], ". |
| 52 | + "'#{$pLineColor}', {$pStroke} , {$lineOpacity}, ". |
| 53 | + "'#{$pFillColor}', {$fillOpacity}, {'clickable': false})); "; |
| 54 | + } else { |
| 55 | + // build the javascript for adding the polyline |
| 56 | + $this->mOutput .= " map.addOverlay(new GPolyline( [ " . implode( ", ", $polyline )." ], ". |
| 57 | + "'#{$pLineColor}', {$pStroke}, {$lineOpacity}, {'clickable': false})); "; |
| 58 | + } |
| 59 | + } |
60 | 60 | |
61 | | - /** |
62 | | - * Creates a new marker on the google map. |
63 | | - * |
64 | | - * @param $pLat numeric - the latitude for the marker |
65 | | - * @param $pLon numeric - the longitude of the marker |
66 | | - * @param $pIcon string - the identifier of the icon to use |
67 | | - * @param $pTitle string - the title for the marker |
68 | | - * @param $pCaption string - the caption for the marker |
69 | | - * @param $pColor string - the color of the polyline (really just used to know if we're in |
70 | | - * a polyline or not and should draw markers without captions) |
71 | | - * @param $pTabs [string] - array of tabs for the marker formatted as javascript for constructing |
72 | | - * GInfoWindowTab objects |
73 | | - * |
74 | | - * @return string - the javascript for adding the tabs to the map |
75 | | - **/ |
| 61 | + /** |
| 62 | + * Creates a new marker on the google map. |
| 63 | + * |
| 64 | + * @param $pLat numeric - the latitude for the marker |
| 65 | + * @param $pLon numeric - the longitude of the marker |
| 66 | + * @param $pIcon string - the identifier of the icon to use |
| 67 | + * @param $pTitle string - the title for the marker |
| 68 | + * @param $pCaption string - the caption for the marker |
| 69 | + * @param $pColor string - the color of the polyline (really just used to know if we're in |
| 70 | + * a polyline or not and should draw markers without captions) |
| 71 | + * @param $pTabs [string] - array of tabs for the marker formatted as javascript for constructing |
| 72 | + * GInfoWindowTab objects |
| 73 | + * |
| 74 | + * @return string - the javascript for adding the tabs to the map |
| 75 | + **/ |
76 | 76 | |
77 | | - function addMarker ( $pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine ) { |
78 | | - $title = GoogleMaps::fixStringDirection($pTitle, $this->mLanguage->isRTL()); |
| 77 | + function addMarker ( $pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine ) { |
| 78 | + $title = GoogleMaps::fixStringDirection($pTitle, $this->mLanguage->isRTL()); |
79 | 79 | |
80 | | - if (is_string($pCaption)) { |
81 | | - $captionNoNewlines = preg_replace('/[\r\n]+/', ' ', $pCaption); |
82 | | - } |
83 | | - $options = array(); |
84 | | - // choose the appropriate icon for the marker |
85 | | - $options['icon'] = $pIcon ? "mapIcons['{$pIcon}']" : "GME_DEFAULT_ICON"; |
86 | | - $options['clickable'] = $title || (is_string($pCaption) ? $captionNoNewlines : count($pCaption)) ? "true" : "false"; |
| 80 | + if (is_string($pCaption)) { |
| 81 | + $captionNoNewlines = preg_replace('/[\r\n]+/', ' ', $pCaption); |
| 82 | + } |
| 83 | + $options = array(); |
| 84 | + // choose the appropriate icon for the marker |
| 85 | + $options['icon'] = $pIcon ? "mapIcons['{$pIcon}']" : "GME_DEFAULT_ICON"; |
| 86 | + $options['clickable'] = $title || (is_string($pCaption) ? $captionNoNewlines : count($pCaption)) ? "true" : "false"; |
87 | 87 | |
88 | | - if (!($pIsLine && $options['clickable'] == "false")) { |
89 | | - $this->mOutput .= " marker = new GMarker(new GLatLng({$pLat}, {$pLon}), { "; |
90 | | - if ($title) { |
91 | | - $this->mOutput .= " 'title': '".addslashes($title)."', "; |
92 | | - } |
93 | | - $this->mOutput .= " 'icon': {$options['icon']}, "; |
94 | | - $this->mOutput .= " 'clickable': {$options['clickable']} "; |
95 | | - $this->mOutput .= "});"; |
96 | | - } |
97 | | - if ($pMaxContent) { |
98 | | - $this->mOutput .= " marker.maxContent = '".addslashes($pMaxContent)."';"; |
99 | | - } |
| 88 | + if (!($pIsLine && $options['clickable'] == "false")) { |
| 89 | + $this->mOutput .= " marker = new GMarker(new GLatLng({$pLat}, {$pLon}), { "; |
| 90 | + if ($title) { |
| 91 | + $this->mOutput .= " 'title': '".addslashes($title)."', "; |
| 92 | + } |
| 93 | + $this->mOutput .= " 'icon': {$options['icon']}, "; |
| 94 | + $this->mOutput .= " 'clickable': {$options['clickable']} "; |
| 95 | + $this->mOutput .= "});"; |
| 96 | + } |
| 97 | + if ($pMaxContent) { |
| 98 | + $this->mOutput .= " marker.maxContent = '".addslashes($pMaxContent)."';"; |
| 99 | + } |
100 | 100 | |
101 | | - if (is_string($pCaption)) { |
102 | | - // if there's a caption, set it |
103 | | - $this->mOutput .= " marker.caption = '';"; |
104 | | - if ($title) { |
105 | | - $this->mOutput .= " marker.title = '".addslashes($title)."';"; |
106 | | - $this->mOutput .= " marker.title_link = '".addslashes($pTitleLink)."';"; |
107 | | - } |
108 | | - if( $captionNoNewlines ) { |
109 | | - $this->mOutput .= " marker.caption += '" . |
110 | | - addslashes( GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($captionNoNewlines), $this->mLanguage->isRTL())) . |
111 | | - "';"; |
112 | | - } |
113 | | - // if there's tabs add them to the marker |
114 | | - } elseif( is_array($pCaption) && count($pCaption) ) { // dump the tabs from the previous marker |
115 | | - $tabs = array(); |
116 | | - foreach($pCaption as $t) { |
117 | | - $tabs[] = "new GInfoWindowTab('" . |
118 | | - addslashes(GoogleMaps::fixStringDirection($t['title'], $this->mLanguage->isRTL())). |
119 | | - "', '". |
120 | | - addslashes(preg_replace('/[\r\n]+/', ' ', GoogleMaps::fixBlockDirection( |
121 | | - GoogleMaps::fixTidy($t['gm-caption']), $this->mLanguage->isRTL()))) . |
122 | | - "')"; |
123 | | - } |
124 | | - $this->mOutput .= " marker.tabs = [ ".implode(',', $tabs)." ]; "; |
125 | | - } |
| 101 | + if (is_string($pCaption)) { |
| 102 | + // if there's a caption, set it |
| 103 | + $this->mOutput .= " marker.caption = '';"; |
| 104 | + if ($title) { |
| 105 | + $this->mOutput .= " marker.title = '".addslashes($title)."';"; |
| 106 | + $this->mOutput .= " marker.title_link = '".addslashes($pTitleLink)."';"; |
| 107 | + } |
| 108 | + if( $captionNoNewlines ) { |
| 109 | + $this->mOutput .= " marker.caption += '" . |
| 110 | + addslashes( GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($captionNoNewlines), $this->mLanguage->isRTL())) . |
| 111 | + "';"; |
| 112 | + } |
| 113 | + // if there's tabs add them to the marker |
| 114 | + } elseif( is_array($pCaption) && count($pCaption) ) { // dump the tabs from the previous marker |
| 115 | + $tabs = array(); |
| 116 | + foreach($pCaption as $t) { |
| 117 | + $tabs[] = "new GInfoWindowTab('" . |
| 118 | + addslashes(GoogleMaps::fixStringDirection($t['title'], $this->mLanguage->isRTL())). |
| 119 | + "', '". |
| 120 | + addslashes(preg_replace('/[\r\n]+/', ' ', GoogleMaps::fixBlockDirection( |
| 121 | + GoogleMaps::fixTidy($t['gm-caption']), $this->mLanguage->isRTL()))) . |
| 122 | + "')"; |
| 123 | + } |
| 124 | + $this->mOutput .= " marker.tabs = [ ".implode(',', $tabs)." ]; "; |
| 125 | + } |
126 | 126 | |
127 | | - // add the marker to the map |
128 | | - $this->mOutput .= " map.addOverlay(marker);"; |
129 | | - } |
| 127 | + // add the marker to the map |
| 128 | + $this->mOutput .= " map.addOverlay(marker);"; |
| 129 | + } |
130 | 130 | |
131 | | - function addIcon($icon, $options) { |
132 | | - $this->mOutput .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '" . |
133 | | - addslashes( str_replace( "{label}", $icon, $options['icons']) ) . "');"; |
134 | | - list($x, $y) = sscanf($options['iconsize'], "%dx%d"); |
135 | | - if (!is_null($x) && !is_null($y)) { |
136 | | - $this->mOutput .= " mapIcons['{$icon}'].iconSize = new GSize({$x}, {$y});"; |
137 | | - } |
138 | | - list($x, $y) = sscanf($options['shadowsize'], "%dx%d"); |
139 | | - if (!is_null($x) && !is_null($y)) { |
140 | | - $this->mOutput .= " mapIcons['{$icon}'].shadowSize = new GSize({$x}, {$y});"; |
141 | | - } |
142 | | - list($x, $y) = sscanf($options['iconanchor'], "%dx%d"); |
143 | | - if (!is_null($x) && !is_null($y)) { |
144 | | - $this->mOutput .= " mapIcons['{$icon}'].iconAnchor = new GPoint({$x}, {$y});"; |
145 | | - } |
146 | | - list($x, $y) = sscanf($options['windowanchor'], "%dx%d"); |
147 | | - if (!is_null($x) && !is_null($y)) { |
148 | | - $this->mOutput .= " mapIcons['{$icon}'].infoWindowAnchor = new GPoint({$x}, {$y});"; |
149 | | - } |
150 | | - $this->mOutput .= " mapIcons['{$icon}'].shadow = '{$options['shadow']}';"; |
151 | | - } |
| 131 | + function addIcon($icon, $options) { |
| 132 | + $this->mOutput .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '" . |
| 133 | + addslashes( str_replace( "{label}", $icon, $options['icons']) ) . "');"; |
| 134 | + list($x, $y) = sscanf($options['iconsize'], "%dx%d"); |
| 135 | + if (!is_null($x) && !is_null($y)) { |
| 136 | + $this->mOutput .= " mapIcons['{$icon}'].iconSize = new GSize({$x}, {$y});"; |
| 137 | + } |
| 138 | + list($x, $y) = sscanf($options['shadowsize'], "%dx%d"); |
| 139 | + if (!is_null($x) && !is_null($y)) { |
| 140 | + $this->mOutput .= " mapIcons['{$icon}'].shadowSize = new GSize({$x}, {$y});"; |
| 141 | + } |
| 142 | + list($x, $y) = sscanf($options['iconanchor'], "%dx%d"); |
| 143 | + if (!is_null($x) && !is_null($y)) { |
| 144 | + $this->mOutput .= " mapIcons['{$icon}'].iconAnchor = new GPoint({$x}, {$y});"; |
| 145 | + } |
| 146 | + list($x, $y) = sscanf($options['windowanchor'], "%dx%d"); |
| 147 | + if (!is_null($x) && !is_null($y)) { |
| 148 | + $this->mOutput .= " mapIcons['{$icon}'].infoWindowAnchor = new GPoint({$x}, {$y});"; |
| 149 | + } |
| 150 | + $this->mOutput .= " mapIcons['{$icon}'].shadow = '{$options['shadow']}';"; |
| 151 | + } |
152 | 152 | |
153 | | - function addHeader($o, $fallback) { |
154 | | - $numberOfMaps = $o['number_of_maps']; |
155 | | - $incompatibleMessage = $o['incompatible_message']; |
156 | | - $incompatibleMessageLink = $o['incompatible_message_link']; |
157 | | - $mapType = self::convertMapType($o['world'], $o['type']); |
158 | | - $mapTypeArray = self::getMapTypeArray($o['world']); |
159 | | - // output the main dif with the specified height/width/direction |
160 | | - $this->mOutput .= '<div id="map' . $numberOfMaps . '" style="width: ' . $o['width'].'px; height: ' . $o['height'].'px; direction: ltr; '.$o['style'].'">'; |
161 | | - $this->mOutput .= '<noscript>'.$fallback.'</noscript><div id="map'.$numberOfMaps.'_fallback" style="display: none;">'.$fallback.'</div></div>'; |
| 153 | + function addHeader($o, $fallback) { |
| 154 | + $numberOfMaps = $o['number_of_maps']; |
| 155 | + $incompatibleMessage = $o['incompatible_message']; |
| 156 | + $incompatibleMessageLink = $o['incompatible_message_link']; |
| 157 | + $mapType = self::convertMapType($o['world'], $o['type']); |
| 158 | + $mapTypeArray = self::getMapTypeArray($o['world']); |
| 159 | + // output the main dif with the specified height/width/direction |
| 160 | + $this->mOutput .= '<div id="map' . $numberOfMaps . '" style="width: ' . $o['width'].'px; height: ' . $o['height'].'px; direction: ltr; '.$o['style'].'">'; |
| 161 | + $this->mOutput .= '<noscript>'.$fallback.'</noscript><div id="map'.$numberOfMaps.'_fallback" style="display: none;">'.$fallback.'</div></div>'; |
162 | 162 | |
163 | | - // The Google Maps API shows polylines incorrectly in IE if the direction |
164 | | - // of the Map is RTL. So for RTL languages, we set the map div to LTR, |
165 | | - // then make the info balloons RTL. |
| 163 | + // The Google Maps API shows polylines incorrectly in IE if the direction |
| 164 | + // of the Map is RTL. So for RTL languages, we set the map div to LTR, |
| 165 | + // then make the info balloons RTL. |
166 | 166 | |
167 | | - // wrap the JS block with a token which will be stripped later |
168 | | - $this->mOutput .= '%%BEGINJAVASCRIPT' . $this->mProxyKey . '%%'; |
| 167 | + // wrap the JS block with a token which will be stripped later |
| 168 | + $this->mOutput .= '%%BEGINJAVASCRIPT' . $this->mProxyKey . '%%'; |
169 | 169 | |
170 | | - // We have a JS function specific to each map on the page. |
171 | | - // Note that we now have one click listener per map, rather |
172 | | - // than one per marker. This speeds things up a lot. |
173 | | - $this->mOutput .= <<<JAVASCRIPT |
174 | | - function makeMap{$numberOfMaps}() { |
175 | | - if (!GBrowserIsCompatible()) { |
176 | | - document.getElementById("map{$numberOfMaps}_fallback").style.display = ''; |
177 | | - return; |
178 | | - } |
179 | | - var map = new GMap2(document.getElementById("map{$numberOfMaps}"), { 'mapTypes': {$mapTypeArray} }); |
180 | | - GME_DEFAULT_ICON = G_DEFAULT_ICON; |
181 | | - map.setCenter(new GLatLng({$o['lat']}, {$o['lon']}), {$o['zoom']}, {$mapType}); |
182 | | - GEvent.addListener(map, 'click', function(overlay, point) { |
183 | | - if (overlay) { |
184 | | - if (overlay.tabs) { |
185 | | - overlay.openInfoWindowTabsHtml(overlay.tabs); |
186 | | - } elseif (overlay.title_link || overlay.caption || overlay.maxContent) { |
187 | | - overlay.openInfoWindowHtml('<div class="gmapinfowindow">'+ |
188 | | - (overlay.title?('<b>'+overlay.title_link+'</b><br />'):'')+overlay.caption+'</div>', |
189 | | - { 'maxTitle': overlay.maxContent?overlay.title:undefined, 'maxContent': overlay.maxContent }); |
190 | | - if (overlay.maxContent) { |
191 | | - map.getInfoWindow().enableMaximize(); |
192 | | - } else { |
193 | | - map.getInfoWindow().disableMaximize(); |
194 | | - } |
195 | | - } |
196 | | - } |
197 | | - }); |
| 170 | + // We have a JS function specific to each map on the page. |
| 171 | + // Note that we now have one click listener per map, rather |
| 172 | + // than one per marker. This speeds things up a lot. |
| 173 | + $this->mOutput .= <<<JAVASCRIPT |
| 174 | + function makeMap{$numberOfMaps}() { |
| 175 | + if (!GBrowserIsCompatible()) { |
| 176 | + document.getElementById("map{$numberOfMaps}_fallback").style.display = ''; |
| 177 | + return; |
| 178 | + } |
| 179 | + var map = new GMap2(document.getElementById("map{$numberOfMaps}"), { 'mapTypes': {$mapTypeArray} }); |
| 180 | + GME_DEFAULT_ICON = G_DEFAULT_ICON; |
| 181 | + map.setCenter(new GLatLng({$o['lat']}, {$o['lon']}), {$o['zoom']}, {$mapType}); |
| 182 | + GEvent.addListener(map, 'click', function(overlay, point) { |
| 183 | + if (overlay) { |
| 184 | + if (overlay.tabs) { |
| 185 | + overlay.openInfoWindowTabsHtml(overlay.tabs); |
| 186 | + } elseif (overlay.title_link || overlay.caption || overlay.maxContent) { |
| 187 | + overlay.openInfoWindowHtml('<div class="gmapinfowindow">'+ |
| 188 | + (overlay.title?('<b>'+overlay.title_link+'</b><br />'):'')+overlay.caption+'</div>', |
| 189 | + { 'maxTitle': overlay.maxContent?overlay.title:undefined, 'maxContent': overlay.maxContent }); |
| 190 | + if (overlay.maxContent) { |
| 191 | + map.getInfoWindow().enableMaximize(); |
| 192 | + } else { |
| 193 | + map.getInfoWindow().disableMaximize(); |
| 194 | + } |
| 195 | + } |
| 196 | + } |
| 197 | + }); |
198 | 198 | JAVASCRIPT; |
199 | | - // make gmap api calls to implement the various settings |
200 | | - if( $o['zoomstyle'] == 'smooth' ) { |
201 | | - $this->mOutput .= ' map.enableContinuousZoom(); '; |
202 | | - } |
203 | | - if( $o['doubleclick'] == 'zoom' ) { |
204 | | - $this->mOutput .= ' map.enableDoubleClickZoom(); '; |
205 | | - } |
206 | | - if( $o['scrollwheel'] == 'zoom') { |
207 | | - $this->mOutput .= ' map.enableScrollWheelZoom(); '; |
208 | | - } |
209 | | - if( $o['scale'] == 'yes' ) { |
210 | | - $this->mOutput .= ' map.addControl(new GScaleControl()); '; |
211 | | - } |
212 | | - if( $o['selector'] == 'yes' ) { |
213 | | - $this->mOutput .= ' map.addControl(new GHierarchicalMapTypeControl()); '; |
214 | | - } |
215 | | - if( $o['overview'] == 'yes' ) { |
216 | | - $this->mOutput .= ' map.addControl(new GOverviewMapControl()); '; |
217 | | - } |
218 | | - if( $o['controls'] != 'none' ) { |
219 | | - $this->mOutput .= ' map.addControl(new '.$o['controls'].'()); '; |
220 | | - } |
221 | | - if( $o['icon'] != 'http://www.google.com/mapfiles/marker.png' ) { |
222 | | - $this->mOutput .= " GME_DEFAULT_ICON = new GIcon(G_DEFAULT_ICON, '".addslashes($o['icon'])."');"; |
223 | | - } |
224 | | - } |
| 199 | + // make gmap api calls to implement the various settings |
| 200 | + if( $o['zoomstyle'] == 'smooth' ) { |
| 201 | + $this->mOutput .= ' map.enableContinuousZoom(); '; |
| 202 | + } |
| 203 | + if( $o['doubleclick'] == 'zoom' ) { |
| 204 | + $this->mOutput .= ' map.enableDoubleClickZoom(); '; |
| 205 | + } |
| 206 | + if( $o['scrollwheel'] == 'zoom') { |
| 207 | + $this->mOutput .= ' map.enableScrollWheelZoom(); '; |
| 208 | + } |
| 209 | + if( $o['scale'] == 'yes' ) { |
| 210 | + $this->mOutput .= ' map.addControl(new GScaleControl()); '; |
| 211 | + } |
| 212 | + if( $o['selector'] == 'yes' ) { |
| 213 | + $this->mOutput .= ' map.addControl(new GHierarchicalMapTypeControl()); '; |
| 214 | + } |
| 215 | + if( $o['overview'] == 'yes' ) { |
| 216 | + $this->mOutput .= ' map.addControl(new GOverviewMapControl()); '; |
| 217 | + } |
| 218 | + if( $o['controls'] != 'none' ) { |
| 219 | + $this->mOutput .= ' map.addControl(new '.$o['controls'].'()); '; |
| 220 | + } |
| 221 | + if( $o['icon'] != 'http://www.google.com/mapfiles/marker.png' ) { |
| 222 | + $this->mOutput .= " GME_DEFAULT_ICON = new GIcon(G_DEFAULT_ICON, '".addslashes($o['icon'])."');"; |
| 223 | + } |
| 224 | + } |
225 | 225 | |
226 | | - function addTrailer($options) { |
227 | | - $numberOfMaps = $options['number_of_maps']; |
228 | | - // reset the default icon |
229 | | - $this->mOutput .= " GME_DEFAULT_ICON = G_DEFAULT_ICON;"; |
230 | | - // set the text direction explicitly if it's rtl |
231 | | - if( $this->mLanguage->isRTL() ) { |
232 | | - $this->mOutput .= " document.getElementById('map{$numberOfMaps}').style.direction = 'rtl'; "; |
233 | | - } |
| 226 | + function addTrailer($options) { |
| 227 | + $numberOfMaps = $options['number_of_maps']; |
| 228 | + // reset the default icon |
| 229 | + $this->mOutput .= " GME_DEFAULT_ICON = G_DEFAULT_ICON;"; |
| 230 | + // set the text direction explicitly if it's rtl |
| 231 | + if( $this->mLanguage->isRTL() ) { |
| 232 | + $this->mOutput .= " document.getElementById('map{$numberOfMaps}').style.direction = 'rtl'; "; |
| 233 | + } |
234 | 234 | |
235 | | - $this->mOutput .= '} addLoadEvent(makeMap' . $numberOfMaps . ');%%ENDJAVASCRIPT' . |
236 | | - $this->mProxyKey . '%%'; |
237 | | - } |
| 235 | + $this->mOutput .= '} addLoadEvent(makeMap' . $numberOfMaps . ');%%ENDJAVASCRIPT' . |
| 236 | + $this->mProxyKey . '%%'; |
| 237 | + } |
238 | 238 | |
239 | | - static function convertMapType($world, $type) { |
240 | | - $types = array( |
241 | | - 'earth' => array( |
242 | | - 'map' => 'G_NORMAL_MAP', |
243 | | - 'normal' => 'G_NORMAL_MAP', |
244 | | - 'hybrid' => 'G_HYBRID_MAP', |
245 | | - 'terrain' => 'G_PHYSICAL_MAP', |
246 | | - 'satellite' => 'G_SATELLITE_MAP' |
247 | | - ), |
248 | | - 'moon' => array( |
249 | | - 'map' => 'G_MOON_VISIBLE_MAP', |
250 | | - 'elevation' => 'G_MOON_ELEVATION_MAP' |
251 | | - ), |
252 | | - 'mars' => array( |
253 | | - 'map' => 'G_MARS_VISIBLE_MAP', |
254 | | - 'infrared' => 'G_MARS_INFRARED_MAP' |
255 | | - ) |
256 | | - ); |
257 | | - if (isset($types[$world][$type])) { |
258 | | - return $types[$world][$type]; |
259 | | - } |
260 | | - return $types[$world][0]; |
261 | | - } |
| 239 | + static function convertMapType($world, $type) { |
| 240 | + $types = array( |
| 241 | + 'earth' => array( |
| 242 | + 'map' => 'G_NORMAL_MAP', |
| 243 | + 'normal' => 'G_NORMAL_MAP', |
| 244 | + 'hybrid' => 'G_HYBRID_MAP', |
| 245 | + 'terrain' => 'G_PHYSICAL_MAP', |
| 246 | + 'satellite' => 'G_SATELLITE_MAP' |
| 247 | + ), |
| 248 | + 'moon' => array( |
| 249 | + 'map' => 'G_MOON_VISIBLE_MAP', |
| 250 | + 'elevation' => 'G_MOON_ELEVATION_MAP' |
| 251 | + ), |
| 252 | + 'mars' => array( |
| 253 | + 'map' => 'G_MARS_VISIBLE_MAP', |
| 254 | + 'infrared' => 'G_MARS_INFRARED_MAP' |
| 255 | + ) |
| 256 | + ); |
| 257 | + if (isset($types[$world][$type])) { |
| 258 | + return $types[$world][$type]; |
| 259 | + } |
| 260 | + return $types[$world][0]; |
| 261 | + } |
262 | 262 | |
263 | | - static function getMapTypeArray($world) { |
264 | | - if ($world == 'earth') { |
265 | | - return '[G_NORMAL_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_MAP]'; |
266 | | - } |
267 | | - if ($world == 'moon') { |
268 | | - return 'G_MOON_MAP_TYPES'; |
269 | | - } |
270 | | - if ($world == 'mars') { |
271 | | - return 'G_MARS_MAP_TYPES'; |
272 | | - } |
273 | | - return '[]'; |
274 | | - } |
| 263 | + static function getMapTypeArray($world) { |
| 264 | + if ($world == 'earth') { |
| 265 | + return '[G_NORMAL_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_MAP]'; |
| 266 | + } |
| 267 | + if ($world == 'moon') { |
| 268 | + return 'G_MOON_MAP_TYPES'; |
| 269 | + } |
| 270 | + if ($world == 'mars') { |
| 271 | + return 'G_MARS_MAP_TYPES'; |
| 272 | + } |
| 273 | + return '[]'; |
| 274 | + } |
275 | 275 | |
276 | | - // strip out the tabs and newlines |
277 | | - function render() { |
278 | | - return preg_replace( '/[\t\n]/', ' ', $this->mOutput ); |
279 | | - } |
| 276 | + // strip out the tabs and newlines |
| 277 | + function render() { |
| 278 | + return preg_replace( '/[\t\n]/', ' ', $this->mOutput ); |
| 279 | + } |
280 | 280 | } |