Index: branches/Maps0.8/includes/Maps_Geocoders.php |
— | — | @@ -141,6 +141,10 @@ |
142 | 142 | * @return array with coordinates or false |
143 | 143 | */ |
144 | 144 | public static function geocode( $address, $geoService = '', $mappingService = false ) { |
| 145 | + if ( !is_string( $address ) ) { |
| 146 | + throw new Exception( 'Parameter $address must be a string at ' . __METHOD__ ); |
| 147 | + } |
| 148 | + |
145 | 149 | if ( !self::canGeocode() ) { |
146 | 150 | return false; |
147 | 151 | } |
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -222,6 +222,8 @@ |
223 | 223 | |
224 | 224 | $dependencies = array(); |
225 | 225 | |
| 226 | + $dependencies[] = Html::linkedScript( "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" ); |
| 227 | + |
226 | 228 | $dependencies[] = Html::inlineScript( |
227 | 229 | 'var googleMapsKey = '. json_encode( $egGoogleMapsKey ) . ';' . |
228 | 230 | 'var googleMapsKeys = '. json_encode( $egGoogleMapsKeys ) . ';' . |
Index: branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js |
— | — | @@ -10,43 +10,49 @@ |
11 | 11 | * This means that when the API is loaded, not all modules will have yet, so we need to |
12 | 12 | * wait untill they are available before setting up the maps. Try every 100ms. |
13 | 13 | */ |
14 | | -function loadGoogleMaps() { |
15 | | - if ( typeof GLayer == 'undefined' ) { |
16 | | - setTimeout( function() { loadGoogleMaps(); }, 100 ); |
17 | | - } |
18 | | - else { |
19 | | - if ( GBrowserIsCompatible() ) { |
20 | | - window.unload = GUnload; |
21 | | - |
22 | | - window.GOverlays = [ |
23 | | - new GLayer("com.panoramio.all"), |
24 | | - new GLayer("com.youtube.all"), |
25 | | - new GLayer("org.wikipedia.en"), |
26 | | - new GLayer("com.google.webcams") |
27 | | - ]; |
28 | | - |
29 | | - for ( i in window.maps.googlemaps2 ) { |
30 | | - var map = new GoogleMap( jQuery, window.maps.googlemaps2[i] ); |
31 | | - map.initiate( i ); |
32 | | - } |
33 | | - } |
34 | | - else { |
35 | | - alert( mediaWiki.msg( 'maps-googlemaps2-incompatbrowser' ) ); |
36 | | - |
37 | | - for ( i in window.maps.googlemaps2 ) { |
38 | | - // FIXME: common module with message not getting loaded for some reason |
39 | | - jQuery( '#' + i ).text( mediaWiki.msg( 'maps-load-failed' ) ); |
40 | | - } |
41 | | - } |
42 | | - } |
| 14 | +function loadGoogleMaps( i ) { |
| 15 | + //if ( typeof GLayer == 'undefined' && i < 30 ) { |
| 16 | + // setTimeout( function() { loadGoogleMaps( i + 1 ); }, 100 ); |
| 17 | + //} |
| 18 | + //else { |
| 19 | + |
| 20 | + //} |
43 | 21 | } |
44 | 22 | |
45 | 23 | // Load the Google Maps v2 API. |
| 24 | +/* |
46 | 25 | jQuery.getScript( |
47 | 26 | 'http://maps.google.com/maps?file=api&v=2&key=' + window.googleMapsKey + '&hl=' + window.googleLangCode, |
48 | | - function () { loadGoogleMaps(); } |
| 27 | + function () { loadGoogleMaps( 0 ); } |
49 | 28 | ); |
| 29 | +*/ |
50 | 30 | |
| 31 | +jQuery(document).ready(function() { |
| 32 | + if ( GBrowserIsCompatible() ) { |
| 33 | + window.unload = GUnload; |
| 34 | + |
| 35 | + window.GOverlays = [ |
| 36 | + new GLayer("com.panoramio.all"), |
| 37 | + new GLayer("com.youtube.all"), |
| 38 | + new GLayer("org.wikipedia.en"), |
| 39 | + new GLayer("com.google.webcams") |
| 40 | + ]; |
| 41 | + |
| 42 | + for ( i in window.maps.googlemaps2 ) { |
| 43 | + var map = new GoogleMap( jQuery, window.maps.googlemaps2[i] ); |
| 44 | + map.initiate( i ); |
| 45 | + } |
| 46 | + } |
| 47 | + else { |
| 48 | + alert( mediaWiki.msg( 'maps-googlemaps2-incompatbrowser' ) ); |
| 49 | + |
| 50 | + for ( i in window.maps.googlemaps2 ) { |
| 51 | + // FIXME: common module with message not getting loaded for some reason |
| 52 | + jQuery( '#' + i ).text( mediaWiki.msg( 'maps-load-failed' ) ); |
| 53 | + } |
| 54 | + } |
| 55 | +}); |
| 56 | + |
51 | 57 | var GoogleMap = function( $, args ) { |
52 | 58 | var args = cleanParameters( args ); |
53 | 59 | |
— | — | @@ -55,7 +61,7 @@ |
56 | 62 | } |
57 | 63 | |
58 | 64 | function cleanParameters( args ) { |
59 | | - |
| 65 | + /* |
60 | 66 | args.type = eval( args.type ); |
61 | 67 | var ts=[]; |
62 | 68 | var t; |
— | — | @@ -65,7 +71,7 @@ |
66 | 72 | args.types = ts; |
67 | 73 | |
68 | 74 | args.types = ensureTypeIsSelectable( args.type, args.types ); |
69 | | - |
| 75 | + */ |
70 | 76 | return args; |
71 | 77 | } |
72 | 78 | |
— | — | @@ -74,9 +80,10 @@ |
75 | 81 | */ |
76 | 82 | function createGoogleMap( mapName, args ) { |
77 | 83 | var mapElement = document.getElementById( mapName ); |
78 | | - var map = new GMap2( mapElement, { mapTypes: args.types } ); |
| 84 | + var map = new GMap2( mapElement/*, { mapTypes: args.types }*/ ); |
| 85 | + |
79 | 86 | map.name = mapName; |
80 | | - map.setMapType( args.type ); |
| 87 | + //map.setMapType( args.type ); |
81 | 88 | |
82 | 89 | var hasSearchBar = false; |
83 | 90 | |
— | — | @@ -138,11 +145,10 @@ |
139 | 146 | } |
140 | 147 | } |
141 | 148 | |
142 | | -/* |
143 | | - var bounds = ((mapOptions.zoom == null || mapOptions.centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
| 149 | + var bounds = ((args.zoom == null || args.centre == null) && args.locations.length > 1) ? new GLatLngBounds() : null; |
144 | 150 | |
145 | | - for ( i = markers.length - 1; i >= 0; i-- ) { |
146 | | - var marker = markers[i]; |
| 151 | + for ( i = args.locations.length - 1; i >= 0; i-- ) { |
| 152 | + var marker = args.locations[i]; |
147 | 153 | marker.point = new GLatLng( marker.lat, marker.lon ); |
148 | 154 | map.addOverlay( createGMarker( marker ) ); |
149 | 155 | if ( bounds != null ) bounds.extend( marker.point ); |
— | — | @@ -152,17 +158,24 @@ |
153 | 159 | map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); |
154 | 160 | } |
155 | 161 | |
156 | | - if (mapOptions.centre != null) map.setCenter(mapOptions.centre); |
157 | | - if (mapOptions.zoom != null) map.setZoom(mapOptions.zoom); |
| 162 | + if ( args.centre !== false ) { |
| 163 | + map.setCenter( args.centre ); |
| 164 | + } |
158 | 165 | |
159 | | - if (mapOptions.scrollWheelZoom) map.enableScrollWheelZoom(); |
| 166 | + if ( args.zoom !== false ) { |
| 167 | + map.setZoom( args.zoom ); |
| 168 | + } |
| 169 | + |
| 170 | + if ( args.autozoom ) { |
| 171 | + map.enableScrollWheelZoom(); |
| 172 | + } |
160 | 173 | |
161 | 174 | map.enableContinuousZoom(); |
162 | 175 | |
163 | 176 | // Code to add KML files. |
164 | 177 | var kmlOverlays = []; |
165 | | - for ( i = mapOptions.kml.length - 1; i >= 0; i-- ) { |
166 | | - kmlOverlays[i] = new GGeoXml( mapOptions.kml[i] ); |
| 178 | + for ( i = args.kml.length - 1; i >= 0; i-- ) { |
| 179 | + kmlOverlays[i] = new GGeoXml( args.kml[i] ); |
167 | 180 | map.addOverlay( kmlOverlays[i] ); |
168 | 181 | } |
169 | 182 | |
— | — | @@ -171,7 +184,6 @@ |
172 | 185 | eval("window.GMaps." + mapName + " = map;"); |
173 | 186 | |
174 | 187 | return map; |
175 | | - */ |
176 | 188 | } |
177 | 189 | |
178 | 190 | function ensureTypeIsSelectable( type, types ) { |
— | — | @@ -225,9 +237,9 @@ |
226 | 238 | marker = new GMarker( markerData.point ); |
227 | 239 | } |
228 | 240 | |
229 | | - if ( ( markerData.title + markerData.label ).length != '' ) { |
230 | | - var bothTxtAreSet = markerData.title.length != '' && markerData.label.length != ''; |
231 | | - var popupText = bothTxtAreSet ? '<b>' + markerData.title + '</b><hr />' + markerData.label : markerData.title + markerData.label; |
| 241 | + if ( markerData.title + markerData.text != '' ) { |
| 242 | + var bothTxtAreSet = markerData.title != '' && markerData.text != ''; |
| 243 | + var popupText = bothTxtAreSet ? '<b>' + markerData.title + '</b><hr />' + markerData.label : markerData.title + markerData.text; |
232 | 244 | popupText = '<div style="overflow:auto;max-height:130px;">' + popupText + '</div>'; |
233 | 245 | |
234 | 246 | GEvent.addListener(marker, 'click', |
Index: branches/Maps0.8/includes/Maps_CoordinateParser.php |
— | — | @@ -520,6 +520,10 @@ |
521 | 521 | * @return string |
522 | 522 | */ |
523 | 523 | protected static function parseDMSCoordinate( $coordinate ) { |
| 524 | + if ( !is_string( $coordinate ) ) { |
| 525 | + throw new Exception( 'Parameter $coordinate must be a string at ' . __METHOD__ ); |
| 526 | + } |
| 527 | + |
524 | 528 | $isNegative = $coordinate{0} == '-'; |
525 | 529 | if ( $isNegative ) $coordinate = substr( $coordinate, 1 ); |
526 | 530 | |