Index: branches/Maps0.8/Maps.i18n.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | Available mapping services: $1", |
22 | 22 | 'maps_map' => 'Map', |
23 | 23 | 'maps-loading-map' => 'Loading map...', |
| 24 | + 'maps-load-failed' => 'Could not load the map!', |
24 | 25 | 'maps-markers' => 'Markers', |
25 | 26 | 'maps-others' => 'others', |
26 | 27 | 'maps-ns-layer' => 'Layer', |
— | — | @@ -150,7 +151,8 @@ |
151 | 152 | 'maps_click_to_activate' => 'Click to activate map', |
152 | 153 | 'maps_centred_on' => 'Map centered on $1, $2.', |
153 | 154 | |
154 | | - // Google Maps v2 overlays |
| 155 | + // Google Maps v2 |
| 156 | + 'maps-googlemaps2-incompatbrowser' => 'Your browser is not compatible with Google Maps v2.', |
155 | 157 | 'maps_overlays' => 'Overlays', |
156 | 158 | 'maps_photos' => 'Photos', |
157 | 159 | 'maps_videos' => 'Videos', |
Index: branches/Maps0.8/Maps.php |
— | — | @@ -39,118 +39,130 @@ |
40 | 40 | if ( ! defined( 'Validator_VERSION' ) ) { |
41 | 41 | die( '<b>Error:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.<br />' ); |
42 | 42 | } |
43 | | -else { |
44 | | - define( 'Maps_VERSION', '0.8 alpha' ); |
45 | 43 | |
46 | | - // The different coordinate notations. |
47 | | - define( 'Maps_COORDS_FLOAT', 'float' ); |
48 | | - define( 'Maps_COORDS_DMS', 'dms' ); |
49 | | - define( 'Maps_COORDS_DM', 'dm' ); |
50 | | - define( 'Maps_COORDS_DD', 'dd' ); |
51 | | - |
52 | | - $egMapsScriptPath = ( $wgExtensionAssetsPath === false ? '/extensions' : $wgExtensionAssetsPath ) . '/Maps'; |
53 | | - $egMapsDir = dirname( __FILE__ ) . '/'; |
| 44 | +define( 'Maps_VERSION', '0.8 alpha' ); |
54 | 45 | |
55 | | - $egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION; |
| 46 | +// The different coordinate notations. |
| 47 | +define( 'Maps_COORDS_FLOAT', 'float' ); |
| 48 | +define( 'Maps_COORDS_DMS', 'dms' ); |
| 49 | +define( 'Maps_COORDS_DM', 'dm' ); |
| 50 | +define( 'Maps_COORDS_DD', 'dd' ); |
56 | 51 | |
57 | | - $wgAutoloadClasses['MapsHooks'] = dirname( __FILE__ ) . '/Maps.hooks.php'; |
| 52 | +$egMapsScriptPath = ( $wgExtensionAssetsPath === false ? '/extensions' : $wgExtensionAssetsPath ) . '/Maps'; |
| 53 | +$egMapsDir = dirname( __FILE__ ) . '/'; |
| 54 | + |
| 55 | +$egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION; |
| 56 | + |
| 57 | +$wgAutoloadClasses['MapsHooks'] = dirname( __FILE__ ) . '/Maps.hooks.php'; |
| 58 | + |
| 59 | +// Autoload the "includes/" classes and interfaces. |
| 60 | +$incDir = dirname( __FILE__ ) . '/includes/'; |
| 61 | +$wgAutoloadClasses['MapsMapper'] = $incDir . 'Maps_Mapper.php'; |
| 62 | +$wgAutoloadClasses['MapsCoordinateParser'] = $incDir . 'Maps_CoordinateParser.php'; |
| 63 | +$wgAutoloadClasses['MapsDistanceParser'] = $incDir . 'Maps_DistanceParser.php'; |
| 64 | +$wgAutoloadClasses['MapsGeoFunctions'] = $incDir . 'Maps_GeoFunctions.php'; |
| 65 | +$wgAutoloadClasses['MapsGeocoders'] = $incDir . 'Maps_Geocoders.php'; |
| 66 | +$wgAutoloadClasses['MapsGeocoder'] = $incDir . 'Maps_Geocoder.php'; |
| 67 | +$wgAutoloadClasses['MapsKMLFormatter'] = $incDir . 'Maps_KMLFormatter.php'; |
| 68 | +$wgAutoloadClasses['MapsLayer'] = $incDir . 'Maps_Layer.php'; |
| 69 | +$wgAutoloadClasses['MapsLayerPage'] = $incDir . 'Maps_LayerPage.php'; |
| 70 | +$wgAutoloadClasses['MapsLayers'] = $incDir . 'Maps_Layers.php'; |
| 71 | +$wgAutoloadClasses['MapsLocation'] = $incDir . 'Maps_Location.php'; |
| 72 | +$wgAutoloadClasses['iMappingFeature'] = $incDir . 'iMappingFeature.php'; |
| 73 | +$wgAutoloadClasses['iMappingService'] = $incDir . 'iMappingService.php'; |
| 74 | +$wgAutoloadClasses['MapsMappingServices'] = $incDir . 'Maps_MappingServices.php'; |
| 75 | +$wgAutoloadClasses['MapsMappingService'] = $incDir . 'Maps_MappingService.php'; |
| 76 | +$wgAutoloadClasses['MapsSettings'] = $incDir . 'Maps_Settings.php'; |
| 77 | + |
| 78 | +// Autoload the "includes/criteria/" classes. |
| 79 | +$criDir = $incDir . 'criteria/'; |
| 80 | +$wgAutoloadClasses['CriterionIsDistance'] = $criDir . 'CriterionIsDistance.php'; |
| 81 | +$wgAutoloadClasses['CriterionIsImage'] = $criDir . 'CriterionIsImage.php'; |
| 82 | +$wgAutoloadClasses['CriterionIsLocation'] = $criDir . 'CriterionIsLocation.php'; |
| 83 | +$wgAutoloadClasses['CriterionMapDimension'] = $criDir . 'CriterionMapDimension.php'; |
| 84 | +$wgAutoloadClasses['CriterionMapLayer'] = $criDir . 'CriterionMapLayer.php'; |
| 85 | +unset( $criDir ); |
| 86 | + |
| 87 | +// Autoload the "includes/features/" classes. |
| 88 | +$ftDir = $incDir . '/features/'; |
| 89 | +$wgAutoloadClasses['MapsBaseMap'] = $ftDir . 'Maps_BaseMap.php'; |
| 90 | +$wgAutoloadClasses['MapsBasePointMap'] = $ftDir . 'Maps_BasePointMap.php'; |
| 91 | +unset( $ftDir ); |
| 92 | + |
| 93 | +// Autoload the "includes/geocoders/" classes. |
| 94 | +$geoDir = $incDir . 'geocoders/'; |
| 95 | +$wgAutoloadClasses['MapsGeonamesGeocoder'] = $geoDir . 'Maps_GeonamesGeocoder.php'; |
| 96 | +$wgAutoloadClasses['MapsGoogleGeocoder'] = $geoDir . 'Maps_GoogleGeocoder.php'; |
| 97 | +$wgAutoloadClasses['MapsYahooGeocoder'] = $geoDir . 'Maps_YahooGeocoder.php'; |
| 98 | +unset( $geoDir ); |
| 99 | + |
| 100 | +// Autoload the "includes/layers/" classes. |
| 101 | +$lyrDir = $incDir . 'layers/'; |
| 102 | +$wgAutoloadClasses['MapsImageLayer'] = $lyrDir . 'Maps_ImageLayer.php'; |
| 103 | +$wgAutoloadClasses['MapsKMLLayer'] = $lyrDir . 'Maps_KMLLayer.php'; |
| 104 | +unset( $lyrDir ); |
| 105 | + |
| 106 | +// Autoload the "includes/manipulations/" classes. |
| 107 | +$manDir = $incDir . 'manipulations/'; |
| 108 | +$wgAutoloadClasses['MapsParamDimension'] = $manDir . 'Maps_ParamDimension.php'; |
| 109 | +$wgAutoloadClasses['MapsParamImage'] = $manDir . 'Maps_ParamImage.php'; |
| 110 | +$wgAutoloadClasses['MapsParamLocation'] = $manDir . 'Maps_ParamLocation.php'; |
| 111 | +$wgAutoloadClasses['MapsParamService'] = $manDir . 'Maps_ParamService.php'; |
| 112 | +$wgAutoloadClasses['MapsParamZoom'] = $manDir . 'Maps_ParamZoom.php'; |
| 113 | +unset( $manDir ); |
| 114 | + |
| 115 | +// Autoload the "includes/parserHooks/" classes. |
| 116 | +$phDir = $incDir . '/parserHooks/'; |
| 117 | +$wgAutoloadClasses['MapsCoordinates'] = $phDir . 'Maps_Coordinates.php'; |
| 118 | +$wgAutoloadClasses['MapsDisplayMap'] = $phDir . 'Maps_DisplayMap.php'; |
| 119 | +$wgAutoloadClasses['MapsDisplayPoint'] = $phDir . 'Maps_DisplayPoint.php'; |
| 120 | +$wgAutoloadClasses['MapsDistance'] = $phDir . 'Maps_Distance.php'; |
| 121 | +$wgAutoloadClasses['MapsFinddestination'] = $phDir . 'Maps_Finddestination.php'; |
| 122 | +$wgAutoloadClasses['MapsGeocode'] = $phDir . 'Maps_Geocode.php'; |
| 123 | +$wgAutoloadClasses['MapsGeodistance'] = $phDir . 'Maps_Geodistance.php'; |
| 124 | +unset( $phDir ); |
| 125 | +unset( $incDir ); |
58 | 126 | |
59 | | - // Autoload the "includes/" classes and interfaces. |
60 | | - $incDir = dirname( __FILE__ ) . '/includes/'; |
61 | | - $wgAutoloadClasses['MapsMapper'] = $incDir . 'Maps_Mapper.php'; |
62 | | - $wgAutoloadClasses['MapsCoordinateParser'] = $incDir . 'Maps_CoordinateParser.php'; |
63 | | - $wgAutoloadClasses['MapsDistanceParser'] = $incDir . 'Maps_DistanceParser.php'; |
64 | | - $wgAutoloadClasses['MapsGeoFunctions'] = $incDir . 'Maps_GeoFunctions.php'; |
65 | | - $wgAutoloadClasses['MapsGeocoders'] = $incDir . 'Maps_Geocoders.php'; |
66 | | - $wgAutoloadClasses['MapsGeocoder'] = $incDir . 'Maps_Geocoder.php'; |
67 | | - $wgAutoloadClasses['MapsKMLFormatter'] = $incDir . 'Maps_KMLFormatter.php'; |
68 | | - $wgAutoloadClasses['MapsLayer'] = $incDir . 'Maps_Layer.php'; |
69 | | - $wgAutoloadClasses['MapsLayerPage'] = $incDir . 'Maps_LayerPage.php'; |
70 | | - $wgAutoloadClasses['MapsLayers'] = $incDir . 'Maps_Layers.php'; |
71 | | - $wgAutoloadClasses['MapsLocation'] = $incDir . 'Maps_Location.php'; |
72 | | - $wgAutoloadClasses['iMappingFeature'] = $incDir . 'iMappingFeature.php'; |
73 | | - $wgAutoloadClasses['iMappingService'] = $incDir . 'iMappingService.php'; |
74 | | - $wgAutoloadClasses['MapsMappingServices'] = $incDir . 'Maps_MappingServices.php'; |
75 | | - $wgAutoloadClasses['MapsMappingService'] = $incDir . 'Maps_MappingService.php'; |
76 | | - $wgAutoloadClasses['MapsSettings'] = $incDir . 'Maps_Settings.php'; |
| 127 | +$wgExtensionMessagesFiles['MapsMagic'] = $egMapsDir . 'Maps.i18n.magic.php'; |
77 | 128 | |
78 | | - // Autoload the "includes/criteria/" classes. |
79 | | - $criDir = $incDir . 'criteria/'; |
80 | | - $wgAutoloadClasses['CriterionIsDistance'] = $criDir . 'CriterionIsDistance.php'; |
81 | | - $wgAutoloadClasses['CriterionIsImage'] = $criDir . 'CriterionIsImage.php'; |
82 | | - $wgAutoloadClasses['CriterionIsLocation'] = $criDir . 'CriterionIsLocation.php'; |
83 | | - $wgAutoloadClasses['CriterionMapDimension'] = $criDir . 'CriterionMapDimension.php'; |
84 | | - $wgAutoloadClasses['CriterionMapLayer'] = $criDir . 'CriterionMapLayer.php'; |
85 | | - unset( $criDir ); |
86 | | - |
87 | | - // Autoload the "includes/features/" classes. |
88 | | - $ftDir = $incDir . '/features/'; |
89 | | - $wgAutoloadClasses['MapsBaseMap'] = $ftDir . 'Maps_BaseMap.php'; |
90 | | - $wgAutoloadClasses['MapsBasePointMap'] = $ftDir . 'Maps_BasePointMap.php'; |
91 | | - unset( $ftDir ); |
92 | | - |
93 | | - // Autoload the "includes/geocoders/" classes. |
94 | | - $geoDir = $incDir . 'geocoders/'; |
95 | | - $wgAutoloadClasses['MapsGeonamesGeocoder'] = $geoDir . 'Maps_GeonamesGeocoder.php'; |
96 | | - $wgAutoloadClasses['MapsGoogleGeocoder'] = $geoDir . 'Maps_GoogleGeocoder.php'; |
97 | | - $wgAutoloadClasses['MapsYahooGeocoder'] = $geoDir . 'Maps_YahooGeocoder.php'; |
98 | | - unset( $geoDir ); |
99 | | - |
100 | | - // Autoload the "includes/layers/" classes. |
101 | | - $lyrDir = $incDir . 'layers/'; |
102 | | - $wgAutoloadClasses['MapsImageLayer'] = $lyrDir . 'Maps_ImageLayer.php'; |
103 | | - $wgAutoloadClasses['MapsKMLLayer'] = $lyrDir . 'Maps_KMLLayer.php'; |
104 | | - unset( $lyrDir ); |
105 | | - |
106 | | - // Autoload the "includes/manipulations/" classes. |
107 | | - $manDir = $incDir . 'manipulations/'; |
108 | | - $wgAutoloadClasses['MapsParamDimension'] = $manDir . 'Maps_ParamDimension.php'; |
109 | | - $wgAutoloadClasses['MapsParamImage'] = $manDir . 'Maps_ParamImage.php'; |
110 | | - $wgAutoloadClasses['MapsParamLocation'] = $manDir . 'Maps_ParamLocation.php'; |
111 | | - $wgAutoloadClasses['MapsParamService'] = $manDir . 'Maps_ParamService.php'; |
112 | | - $wgAutoloadClasses['MapsParamZoom'] = $manDir . 'Maps_ParamZoom.php'; |
113 | | - unset( $manDir ); |
114 | | - |
115 | | - // Autoload the "includes/parserHooks/" classes. |
116 | | - $phDir = $incDir . '/parserHooks/'; |
117 | | - $wgAutoloadClasses['MapsCoordinates'] = $phDir . 'Maps_Coordinates.php'; |
118 | | - $wgAutoloadClasses['MapsDisplayMap'] = $phDir . 'Maps_DisplayMap.php'; |
119 | | - $wgAutoloadClasses['MapsDisplayPoint'] = $phDir . 'Maps_DisplayPoint.php'; |
120 | | - $wgAutoloadClasses['MapsDistance'] = $phDir . 'Maps_Distance.php'; |
121 | | - $wgAutoloadClasses['MapsFinddestination'] = $phDir . 'Maps_Finddestination.php'; |
122 | | - $wgAutoloadClasses['MapsGeocode'] = $phDir . 'Maps_Geocode.php'; |
123 | | - $wgAutoloadClasses['MapsGeodistance'] = $phDir . 'Maps_Geodistance.php'; |
124 | | - unset( $phDir ); |
125 | | - unset( $incDir ); |
126 | | - |
127 | | - $wgExtensionMessagesFiles['MapsMagic'] = $egMapsDir . 'Maps.i18n.magic.php'; |
128 | | - |
129 | | - $wgExtensionMessagesFiles['Maps'] = $egMapsDir . 'Maps.i18n.php'; |
| 129 | +$wgExtensionMessagesFiles['Maps'] = $egMapsDir . 'Maps.i18n.php'; |
130 | 130 | |
131 | | - // Register the initialization function of Maps. |
132 | | - $wgExtensionFunctions[] = 'efMapsSetup'; |
| 131 | +// Register the initialization function of Maps. |
| 132 | +$wgExtensionFunctions[] = 'efMapsSetup'; |
133 | 133 | |
134 | | - // Since 0.2 |
135 | | - $wgHooks['AdminLinks'][] = 'MapsHooks::addToAdminLinks'; |
| 134 | +// Since 0.2 |
| 135 | +$wgHooks['AdminLinks'][] = 'MapsHooks::addToAdminLinks'; |
| 136 | + |
| 137 | +// Since 0.6.5 |
| 138 | +$wgHooks['UnitTestsList'][] = 'MapsHooks::registerUnitTests'; |
136 | 139 | |
137 | | - // Since 0.6.5 |
138 | | - $wgHooks['UnitTestsList'][] = 'MapsHooks::registerUnitTests'; |
139 | | - |
140 | | - // Since 0.7 |
141 | | - $wgHooks['SkinAfterBottomScripts'][] = 'MapsHooks::addOnloadFunction'; |
142 | | - |
143 | | - // Since 0.7.1 |
144 | | - $wgHooks['ArticleFromTitle'][] = 'MapsHooks::onArticleFromTitle'; |
145 | | - |
146 | | - $egMapsFeatures = array(); |
147 | | - |
148 | | - // Include the settings file. |
149 | | - require_once $egMapsDir . 'Maps_Settings.php'; |
150 | | - |
151 | | - define( 'Maps_NS_LAYER', $egMapsNamespaceIndex + 0 ); |
152 | | - define( 'Maps_NS_LAYER_TALK', $egMapsNamespaceIndex + 1 ); |
153 | | -} |
| 140 | +// Since 0.7 |
| 141 | +$wgHooks['SkinAfterBottomScripts'][] = 'MapsHooks::addOnloadFunction'; |
154 | 142 | |
| 143 | +// Since 0.7.1 |
| 144 | +$wgHooks['ArticleFromTitle'][] = 'MapsHooks::onArticleFromTitle'; |
| 145 | + |
| 146 | +$egMapsFeatures = array(); |
| 147 | + |
| 148 | +// Include the settings file. |
| 149 | +require_once $egMapsDir . 'Maps_Settings.php'; |
| 150 | + |
| 151 | +define( 'Maps_NS_LAYER', $egMapsNamespaceIndex + 0 ); |
| 152 | +define( 'Maps_NS_LAYER_TALK', $egMapsNamespaceIndex + 1 ); |
| 153 | + |
| 154 | +$wgResourceModules['ext.maps.common'] = array( |
| 155 | + 'localBasePath' => dirname( __FILE__ ) . '/includes', |
| 156 | + 'remoteBasePath' => $egMapsScriptPath . '/includes', |
| 157 | + 'group' => 'ext.maps', |
| 158 | + 'messages' => array( |
| 159 | + 'maps-load-failed', |
| 160 | + ), |
| 161 | + 'scripts' => array( |
| 162 | + 'ext.maps.common.js' |
| 163 | + ) |
| 164 | +); |
| 165 | + |
| 166 | + |
155 | 167 | /** |
156 | 168 | * Initialization function for the Maps extension. |
157 | 169 | * |
Index: branches/Maps0.8/includes/services/GoogleMaps/GoogleMaps.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | $wgResourceModules['ext.maps.googlemaps2'] = array( |
| 25 | + 'dependencies' => array( 'ext.maps.common' ), |
25 | 26 | 'localBasePath' => dirname( __FILE__ ), |
26 | 27 | 'remoteBasePath' => $egMapsScriptPath . '/includes/services/GoogleMaps', |
27 | 28 | 'group' => 'ext.maps', |
— | — | @@ -36,7 +37,8 @@ |
37 | 38 | 'maps_photos', |
38 | 39 | 'maps_videos', |
39 | 40 | 'maps_wikipedia', |
40 | | - 'maps_webcams' |
| 41 | + 'maps_webcams', |
| 42 | + 'maps-googlemaps2-incompatbrowser' |
41 | 43 | ) |
42 | 44 | ); |
43 | 45 | |
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -51,10 +51,7 @@ |
52 | 52 | $params['controls'] = new ListParameter( 'controls' ); |
53 | 53 | $params['controls']->setDefault( $egMapsGMapControls ); |
54 | 54 | $params['controls']->addCriteria( new CriterionInArray( self::getControlNames() ) ); |
55 | | - $params['controls']->addManipulations( |
56 | | - new ParamManipulationFunctions( 'strtolower' ), |
57 | | - new ParamManipulationImplode( ',', "'" ) |
58 | | - ); |
| 55 | + $params['controls']->addManipulations( new ParamManipulationFunctions( 'strtolower' ) ); |
59 | 56 | |
60 | 57 | $params['type'] = new Parameter( |
61 | 58 | 'type', |
— | — | @@ -78,14 +75,13 @@ |
79 | 76 | new CriterionInArray( array_keys( self::$mapTypes ) ), |
80 | 77 | ) |
81 | 78 | ); |
82 | | - $params['types']->addManipulations( new MapsParamGMapType(), new ParamManipulationImplode( ',' ) ); |
| 79 | + $params['types']->addManipulations( new MapsParamGMapType() ); |
83 | 80 | |
84 | 81 | $params['autozoom'] = new Parameter( |
85 | 82 | 'autozoom', |
86 | 83 | Parameter::TYPE_BOOLEAN, |
87 | 84 | $egMapsGoogleAutozoom |
88 | 85 | ); |
89 | | - $params['autozoom']->addManipulations( new ParamManipulationBoolstr() ); |
90 | 86 | |
91 | 87 | $params['kml'] = new ListParameter( 'kml' ); |
92 | 88 | $params['kml']->setDefault( array() ); |
Index: branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js |
— | — | @@ -15,19 +15,29 @@ |
16 | 16 | setTimeout( function() { loadGoogleMaps(); }, 100 ); |
17 | 17 | } |
18 | 18 | else { |
19 | | - window.unload = GUnload; |
20 | | - |
21 | | - window.GOverlays = [ |
22 | | - new GLayer("com.panoramio.all"), |
23 | | - new GLayer("com.youtube.all"), |
24 | | - new GLayer("org.wikipedia.en"), |
25 | | - new GLayer("com.google.webcams") |
26 | | - ]; |
27 | | - |
28 | | - for ( i in window.maps.googlemaps2 ) { |
29 | | - var map = new GoogleMap( jQuery, window.maps.googlemaps2[i] ); |
30 | | - map.initiate( i ); |
| 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 | + } |
31 | 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 | + } |
32 | 42 | } |
33 | 43 | } |
34 | 44 | |
— | — | @@ -38,111 +48,52 @@ |
39 | 49 | ); |
40 | 50 | |
41 | 51 | var GoogleMap = function( $, args ) { |
| 52 | + var args = cleanParameters( args ); |
42 | 53 | |
43 | | - var args = args; |
44 | | - |
45 | 54 | this.initiate = function( mapName ) { |
46 | | - //alert( mapName ); |
| 55 | + createGoogleMap( mapName, args ); |
47 | 56 | } |
48 | 57 | |
49 | | - /** |
50 | | - * Returns GMarker object on the provided location. It will show a popup baloon |
51 | | - * with title and label when clicked, if either of these is set. |
52 | | - */ |
53 | | - function createGMarker( markerData ) { |
54 | | - var marker; |
55 | | - |
56 | | - if ( markerData.icon != '' ) { |
57 | | - var iconObj = new GIcon( G_DEFAULT_ICON ); |
58 | | - iconObj.image = markerData.icon; |
59 | | - |
60 | | - var newimg = new Image(); |
61 | | - newimg.src = markerData.icon; |
62 | | - |
63 | | - // Only do these things when there is an actual width, which there won,t the first time the image is loaded. |
64 | | - // FIXME: this means the image won't have it's correct size when it differs from the default on first load! |
65 | | - if ( newimg.width > 0 ) { |
66 | | - /* Determine size of icon and pass it in */ |
67 | | - iconObj.iconSize.width = newimg.width; |
68 | | - iconObj.iconSize.height = newimg.height; |
69 | | - iconObj.shadow = null; |
70 | | - |
71 | | - /* Anchor the icon on bottom middle */ |
72 | | - var anchor = new GPoint(); |
73 | | - anchor.x = Math.floor( newimg.width / 2 ); |
74 | | - anchor.y = newimg.height; |
75 | | - iconObj.iconAnchor = anchor; |
76 | | - } |
77 | | - |
78 | | - marker = new GMarker( markerData.point, { icon: iconObj } ); |
79 | | - } else { |
80 | | - marker = new GMarker( markerData.point ); |
| 58 | + function cleanParameters( args ) { |
| 59 | + |
| 60 | + args.type = eval( args.type ); |
| 61 | + var ts=[]; |
| 62 | + var t; |
| 63 | + while ( t = args.types.shift() ) { |
| 64 | + ts.unshift( eval( t ) ); |
81 | 65 | } |
| 66 | + args.types = ts; |
82 | 67 | |
83 | | - if ( ( markerData.title + markerData.label ).length != '' ) { |
84 | | - var bothTxtAreSet = markerData.title.length != '' && markerData.label.length != ''; |
85 | | - var popupText = bothTxtAreSet ? '<b>' + markerData.title + '</b><hr />' + markerData.label : markerData.title + markerData.label; |
86 | | - popupText = '<div style="overflow:auto;max-height:130px;">' + popupText + '</div>'; |
| 68 | + args.types = ensureTypeIsSelectable( args.type, args.types ); |
| 69 | + |
| 70 | + return args; |
| 71 | + } |
87 | 72 | |
88 | | - GEvent.addListener(marker, 'click', |
89 | | - function() { |
90 | | - marker.openInfoWindowHtml(popupText, {maxWidth:350}); |
91 | | - } |
92 | | - ); |
93 | | - } |
94 | | - |
95 | | - return marker; |
96 | | - } |
97 | | - |
98 | 73 | /** |
99 | | - * Returns GMap2 object with the provided properties and markers. |
100 | | - * This is done by setting the map centre and size, and passing the arguments to function createGoogleMap. |
101 | | - */ |
102 | | - this.initializeGoogleMap = function(mapName, mapOptions, markers) { |
103 | | - if (GBrowserIsCompatible()) { |
104 | | - mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null; |
105 | | - //mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
106 | | - return createGoogleMap(mapName, mapOptions, markers); |
107 | | - } |
108 | | - else { |
109 | | - return false; |
110 | | - } |
111 | | - } |
112 | | - |
113 | | - /** |
114 | 74 | * Returns GMap2 object with the provided properties. |
115 | 75 | */ |
116 | | - function createGoogleMap(mapName, mapOptions, markers) { |
117 | | - var mapElement = document.getElementById(mapName); |
118 | | - var typesContainType = false; |
119 | | - |
120 | | - for (var i = 0; i < mapOptions.types.length; i++) { |
121 | | - if (mapOptions.types[i] == mapOptions.type) typesContainType = true; |
122 | | - } |
123 | | - |
124 | | - if (! typesContainType) mapOptions.types.push(mapOptions.type); |
125 | | - |
126 | | - var map = new GMap2(mapElement, {mapTypes: mapOptions.types}); |
| 76 | + function createGoogleMap( mapName, args ) { |
| 77 | + var mapElement = document.getElementById( mapName ); |
| 78 | + var map = new GMap2( mapElement, { mapTypes: args.types } ); |
127 | 79 | map.name = mapName; |
| 80 | + map.setMapType( args.type ); |
128 | 81 | |
129 | | - map.setMapType(mapOptions.type); |
130 | | - |
131 | 82 | var hasSearchBar = false; |
132 | 83 | |
133 | | - for ( i = mapOptions.controls.length - 1; i >= 0; i-- ) { |
134 | | - if ( mapOptions.controls[i] == 'searchbar' ) { |
| 84 | + for ( i = args.controls.length - 1; i >= 0; i-- ) { |
| 85 | + if ( args.controls[i] == 'searchbar' ) { |
135 | 86 | hasSearchBar = true; |
136 | 87 | break; |
137 | 88 | } |
138 | 89 | } |
139 | 90 | |
140 | 91 | // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl |
141 | | - for ( i = 0; i < mapOptions.controls.length; i++ ) { |
142 | | - if ( mapOptions.controls[i].toLowerCase() == 'auto' ) { |
143 | | - if ( mapElement.offsetHeight > 75 ) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small'; |
| 92 | + for ( var i = 0, n = args.controls.length; i < n; i++ ) { |
| 93 | + if ( args.controls[i] == 'auto' ) { |
| 94 | + if ( mapElement.offsetHeight > 75 ) args.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small'; |
144 | 95 | } |
145 | | - |
146 | | - switch ( mapOptions.controls[i] ) { |
| 96 | + |
| 97 | + switch ( args.controls[i] ) { |
147 | 98 | case 'large' : |
148 | 99 | map.addControl( new GLargeMapControl3D() ); |
149 | 100 | break; |
— | — | @@ -186,7 +137,8 @@ |
187 | 138 | break; |
188 | 139 | } |
189 | 140 | } |
190 | | - |
| 141 | + |
| 142 | +/* |
191 | 143 | var bounds = ((mapOptions.zoom == null || mapOptions.centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
192 | 144 | |
193 | 145 | for ( i = markers.length - 1; i >= 0; i-- ) { |
— | — | @@ -219,8 +171,75 @@ |
220 | 172 | eval("window.GMaps." + mapName + " = map;"); |
221 | 173 | |
222 | 174 | return map; |
| 175 | + */ |
223 | 176 | } |
| 177 | + |
| 178 | + function ensureTypeIsSelectable( type, types ) { |
| 179 | + var typesContainType = false; |
224 | 180 | |
| 181 | + for ( var i = 0, n = types.length; i < n; i++ ) { |
| 182 | + if ( types[i] == type ) { |
| 183 | + typesContainType = true; |
| 184 | + break; |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + if ( !typesContainType ) { |
| 189 | + types.push( type ); |
| 190 | + } |
| 191 | + |
| 192 | + return types; |
| 193 | + } |
| 194 | + |
| 195 | + /** |
| 196 | + * Returns GMarker object on the provided location. It will show a popup baloon |
| 197 | + * with title and label when clicked, if either of these is set. |
| 198 | + */ |
| 199 | + function createGMarker( markerData ) { |
| 200 | + var marker; |
| 201 | + |
| 202 | + if ( markerData.icon != '' ) { |
| 203 | + var iconObj = new GIcon( G_DEFAULT_ICON ); |
| 204 | + iconObj.image = markerData.icon; |
| 205 | + |
| 206 | + var newimg = new Image(); |
| 207 | + newimg.src = markerData.icon; |
| 208 | + |
| 209 | + // Only do these things when there is an actual width, which there won,t the first time the image is loaded. |
| 210 | + // FIXME: this means the image won't have it's correct size when it differs from the default on first load! |
| 211 | + if ( newimg.width > 0 ) { |
| 212 | + /* Determine size of icon and pass it in */ |
| 213 | + iconObj.iconSize.width = newimg.width; |
| 214 | + iconObj.iconSize.height = newimg.height; |
| 215 | + iconObj.shadow = null; |
| 216 | + |
| 217 | + /* Anchor the icon on bottom middle */ |
| 218 | + var anchor = new GPoint(); |
| 219 | + anchor.x = Math.floor( newimg.width / 2 ); |
| 220 | + anchor.y = newimg.height; |
| 221 | + iconObj.iconAnchor = anchor; |
| 222 | + } |
| 223 | + |
| 224 | + marker = new GMarker( markerData.point, { icon: iconObj } ); |
| 225 | + } else { |
| 226 | + marker = new GMarker( markerData.point ); |
| 227 | + } |
| 228 | + |
| 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; |
| 232 | + popupText = '<div style="overflow:auto;max-height:130px;">' + popupText + '</div>'; |
| 233 | + |
| 234 | + GEvent.addListener(marker, 'click', |
| 235 | + function() { |
| 236 | + marker.openInfoWindowHtml(popupText, {maxWidth:350}); |
| 237 | + } |
| 238 | + ); |
| 239 | + } |
| 240 | + |
| 241 | + return marker; |
| 242 | + } |
| 243 | + |
225 | 244 | function setupCheckboxShiftClick() { return true; } |
226 | 245 | |
227 | 246 | function MoreControl() {}; |
— | — | @@ -240,7 +259,7 @@ |
241 | 260 | var textDiv = document.createElement("div"); |
242 | 261 | textDiv.id = map.name + "-inner-more"; |
243 | 262 | textDiv.setAttribute('class', 'inner-more'); |
244 | | - textDiv.appendChild(document.createTextNode( msgOverlays )); |
| 263 | + textDiv.appendChild(document.createTextNode( mediaWiki.msg( 'maps_overlays' ) )); |
245 | 264 | |
246 | 265 | buttonDiv.appendChild(textDiv); |
247 | 266 | |