Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * A class that holds static helper functions for Open Players |
| 5 | + * Class for handling the Maps parser functions with OpenLayers |
5 | 6 | * |
6 | 7 | * @file Maps_OpenLayers.php |
7 | 8 | * @ingroup Maps |
— | — | @@ -18,115 +19,15 @@ |
19 | 20 | |
20 | 21 | public $serviceName = self::SERVICE_NAME; |
21 | 22 | |
22 | | - private static $loadedBing = false; |
23 | | - private static $loadedYahoo = false; |
24 | | - private static $loadedOL = false; |
25 | | - private static $loadedOSM = false; |
26 | | - |
27 | 23 | /** |
28 | | - * Load the dependencies of a layer if they are not loaded yet |
| 24 | + * @see MapsBaseMap::setMapSettings() |
29 | 25 | * |
30 | | - * @param string $output The output to which the html to load the dependencies needs to be added |
31 | | - * @param string $layer The layer to check (and load the dependencies for |
32 | | - */ |
33 | | - public static function loadDependencyWhenNeeded(&$output, $layer) { |
34 | | - global $wgJsMimeType; |
35 | | - global $egGoogleMapsOnThisPage, $egMapsIncludePath; |
36 | | - |
37 | | - switch ($layer) { |
38 | | - case 'google' : case 'google-normal' : case 'google-sattelite' : case 'google-hybrid' : case 'google-physical' : |
39 | | - if (empty($egGoogleMapsOnThisPage)) { |
40 | | - $egGoogleMapsOnThisPage = 0; |
41 | | - MapsGoogleMaps::addGMapDependencies($output); |
42 | | - } |
43 | | - break; |
44 | | - case 'bing' : case 'virtual-earth' : |
45 | | - if (!self::$loadedBing) { $output .= "<script type='$wgJsMimeType' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>\n"; self::$loadedBing = true; } |
46 | | - break; |
47 | | - case 'yahoo' : case 'yahoo-maps' : |
48 | | - if (!self::$loadedYahoo) { $output .= "<style type='text/css'> #controls {width: 512px;}</style><script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>\n"; self::$loadedYahoo = true; } |
49 | | - break; |
50 | | - case 'openlayers' : case 'open-layers' : |
51 | | - if (!self::$loadedOL) { $output .= "<script type='$wgJsMimeType' src='http://clients.multimap.com/API/maps/1.1/metacarta_04'></script>\n"; self::$loadedOL = true; } |
52 | | - break; |
53 | | - case 'osm' : case 'openstreetmap' : |
54 | | - if (!self::$loadedOSM) { $output .= "<script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OSM/OpenStreetMap.js'></script>\n"; self::$loadedOSM = true; } |
55 | | - break; |
56 | | - } |
57 | | - } |
58 | | - |
59 | | - /** |
60 | | - * Retuns an array holding the default parameters and their values. |
61 | | - * |
62 | | - * @return array |
63 | | - */ |
64 | | - public static function getDefaultParams() { |
65 | | - return array |
66 | | - ( |
67 | | - 'layers' => array(), |
68 | | - 'baselayer' => '' |
69 | | - ); |
70 | | - } |
71 | | - |
72 | | - /** |
73 | | - * If this is the first open layers map on the page, load the API, styles and extra JS functions |
74 | | - * |
75 | | - * @param string $output |
76 | | - */ |
77 | | - public static function addOLDependencies(&$output) { |
78 | | - global $wgJsMimeType; |
79 | | - global $egOpenLayersOnThisPage, $egMapsIncludePath; |
80 | | - |
81 | | - if (empty($egOpenLayersOnThisPage)) { |
82 | | - $egOpenLayersOnThisPage = 0; |
83 | | - |
84 | | - $output .="<link rel='stylesheet' href='$egMapsIncludePath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' /> |
85 | | - <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayers/OpenLayers.js'></script> |
86 | | - <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayerFunctions.js'></script> |
87 | | - <script type='$wgJsMimeType'>setOLPopupType(200, 100);</script>\n"; |
88 | | - } |
89 | | - } |
90 | | - |
91 | | - /** |
92 | | - * Build up a csv string with the layers, to be outputted as a JS array |
93 | | - * |
94 | | - * @param string $output |
95 | | - * @param array $layers |
96 | | - * @return csv string |
97 | | - */ |
98 | | - public static function createLayersStringAndLoadDependencies(&$output, array $layers) { |
99 | | - global $egMapsOLLayers; |
100 | | - |
101 | | - if (count($layers) < 1) $layers = $egMapsOLLayers; |
102 | | - |
103 | | - $layerItems = ''; |
104 | | - foreach ($layers as $layer) { |
105 | | - $layer = strtolower($layer); |
106 | | - $layerItems .= "'$layer'" . ','; |
107 | | - self::loadDependencyWhenNeeded($output, $layer); |
108 | | - } |
109 | | - |
110 | | - return rtrim($layerItems, ','); |
111 | | - } |
112 | | - |
113 | | - /** |
114 | | - * Build up a csv string with the controls, to be outputted as a JS array |
115 | | - * |
116 | | - * @param array $controls |
117 | | - * @return csv string |
118 | | - */ |
119 | | - public static function createControlsString(array $controls) { |
120 | | - global $egMapsOLControls; |
121 | | - return MapsMapper::createJSItemsString($controls, $egMapsOLControls); |
122 | | - } |
123 | | - |
124 | | - /** |
125 | | - * @see MapsBaseMap::setFormInputSettings() |
126 | | - * |
127 | 26 | */ |
128 | 27 | protected function setMapSettings() { |
129 | 28 | global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
130 | 29 | |
| 30 | + $this->defaultParams = MapsOpenLayersUtils::getDefaultParams(); |
| 31 | + |
131 | 32 | $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
132 | 33 | $this->defaultZoom = $egMapsOpenLayersZoom; |
133 | 34 | } |
— | — | @@ -138,7 +39,7 @@ |
139 | 40 | protected function doMapServiceLoad() { |
140 | 41 | global $egOpenLayersOnThisPage; |
141 | 42 | |
142 | | - self::addOLDependencies($this->output); |
| 43 | + MapsOpenLayersUtils::addOLDependencies($this->output); |
143 | 44 | $egOpenLayersOnThisPage++; |
144 | 45 | |
145 | 46 | $this->elementNr = $egOpenLayersOnThisPage; |
— | — | @@ -151,10 +52,10 @@ |
152 | 53 | public function addSpecificMapHTML() { |
153 | 54 | global $wgJsMimeType; |
154 | 55 | |
155 | | - $controlItems = self::createControlsString($this->controls); |
| 56 | + $controlItems = MapsOpenLayersUtils::createControlsString($this->controls); |
156 | 57 | |
157 | 58 | MapsMapper::enforceArrayValues($this->layers); |
158 | | - $layerItems = self::createLayersStringAndLoadDependencies($this->output, $this->layers); |
| 59 | + $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers); |
159 | 60 | |
160 | 61 | MapsUtils::makePxValue($this->width); |
161 | 62 | MapsUtils::makePxValue($this->height); |
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersUtils.php |
— | — | @@ -0,0 +1,122 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * A class that holds static helper functions for OpenLayers
|
| 6 | + *
|
| 7 | + * @file Maps_OpenLayersUtils.php
|
| 8 | + * @ingroup Maps
|
| 9 | + *
|
| 10 | + * @author Jeroen De Dauw
|
| 11 | + */
|
| 12 | +
|
| 13 | +if( !defined( 'MEDIAWIKI' ) ) {
|
| 14 | + die( 'Not an entry point.' );
|
| 15 | +}
|
| 16 | +
|
| 17 | +final class MapsOpenLayersUtils {
|
| 18 | +
|
| 19 | + private static $loadedBing = false;
|
| 20 | + private static $loadedYahoo = false;
|
| 21 | + private static $loadedOL = false;
|
| 22 | + private static $loadedOSM = false;
|
| 23 | +
|
| 24 | + /**
|
| 25 | + * Load the dependencies of a layer if they are not loaded yet
|
| 26 | + *
|
| 27 | + * @param string $output The output to which the html to load the dependencies needs to be added
|
| 28 | + * @param string $layer The layer to check (and load the dependencies for
|
| 29 | + */
|
| 30 | + public static function loadDependencyWhenNeeded(&$output, $layer) {
|
| 31 | + global $wgJsMimeType;
|
| 32 | + global $egGoogleMapsOnThisPage, $egMapsIncludePath;
|
| 33 | +
|
| 34 | + switch ($layer) {
|
| 35 | + case 'google' : case 'google-normal' : case 'google-sattelite' : case 'google-hybrid' : case 'google-physical' :
|
| 36 | + if (empty($egGoogleMapsOnThisPage)) {
|
| 37 | + $egGoogleMapsOnThisPage = 0;
|
| 38 | + self::addGMapDependencies($output);
|
| 39 | + }
|
| 40 | + break;
|
| 41 | + case 'bing' : case 'virtual-earth' :
|
| 42 | + if (!self::$loadedBing) { $output .= "<script type='$wgJsMimeType' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>\n"; self::$loadedBing = true; }
|
| 43 | + break;
|
| 44 | + case 'yahoo' : case 'yahoo-maps' :
|
| 45 | + if (!self::$loadedYahoo) { $output .= "<style type='text/css'> #controls {width: 512px;}</style><script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>\n"; self::$loadedYahoo = true; }
|
| 46 | + break;
|
| 47 | + case 'openlayers' : case 'open-layers' :
|
| 48 | + if (!self::$loadedOL) { $output .= "<script type='$wgJsMimeType' src='http://clients.multimap.com/API/maps/1.1/metacarta_04'></script>\n"; self::$loadedOL = true; }
|
| 49 | + break;
|
| 50 | + case 'osm' : case 'openstreetmap' :
|
| 51 | + if (!self::$loadedOSM) { $output .= "<script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OSM/OpenStreetMap.js'></script>\n"; self::$loadedOSM = true; }
|
| 52 | + break;
|
| 53 | + }
|
| 54 | + }
|
| 55 | +
|
| 56 | + /**
|
| 57 | + * Retuns an array holding the default parameters and their values.
|
| 58 | + *
|
| 59 | + * @return array
|
| 60 | + */
|
| 61 | + public static function getDefaultParams() {
|
| 62 | + return array
|
| 63 | + (
|
| 64 | + 'layers' => array(),
|
| 65 | + 'baselayer' => ''
|
| 66 | + );
|
| 67 | + }
|
| 68 | +
|
| 69 | + /**
|
| 70 | + * If this is the first open layers map on the page, load the API, styles and extra JS functions
|
| 71 | + *
|
| 72 | + * @param string $output
|
| 73 | + */
|
| 74 | + public static function addOLDependencies(&$output) {
|
| 75 | + global $wgJsMimeType;
|
| 76 | + global $egOpenLayersOnThisPage, $egMapsIncludePath;
|
| 77 | +
|
| 78 | + if (empty($egOpenLayersOnThisPage)) {
|
| 79 | + $egOpenLayersOnThisPage = 0;
|
| 80 | +
|
| 81 | + $output .="<link rel='stylesheet' href='$egMapsIncludePath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
|
| 82 | + <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayers/OpenLayers.js'></script>
|
| 83 | + <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayerFunctions.js'></script>
|
| 84 | + <script type='$wgJsMimeType'>setOLPopupType(200, 100);</script>\n";
|
| 85 | + }
|
| 86 | + }
|
| 87 | +
|
| 88 | + /**
|
| 89 | + * Build up a csv string with the layers, to be outputted as a JS array
|
| 90 | + *
|
| 91 | + * @param string $output
|
| 92 | + * @param array $layers
|
| 93 | + * @return csv string
|
| 94 | + */
|
| 95 | + public static function createLayersStringAndLoadDependencies(&$output, array $layers) {
|
| 96 | + global $egMapsOLLayers;
|
| 97 | +
|
| 98 | + if (count($layers) < 1) $layers = $egMapsOLLayers;
|
| 99 | +
|
| 100 | + $layerItems = '';
|
| 101 | + foreach ($layers as $layer) {
|
| 102 | + $layer = strtolower($layer);
|
| 103 | + $layerItems .= "'$layer'" . ',';
|
| 104 | + self::loadDependencyWhenNeeded($output, $layer);
|
| 105 | + }
|
| 106 | +
|
| 107 | + return rtrim($layerItems, ',');
|
| 108 | + }
|
| 109 | +
|
| 110 | + /**
|
| 111 | + * Build up a csv string with the controls, to be outputted as a JS array
|
| 112 | + *
|
| 113 | + * @param array $controls
|
| 114 | + * @return csv string
|
| 115 | + */
|
| 116 | + public static function createControlsString(array $controls) {
|
| 117 | + global $egMapsOLControls;
|
| 118 | + return MapsMapper::createJSItemsString($controls, $egMapsOLControls);
|
| 119 | + }
|
| 120 | +
|
| 121 | +}
|
| 122 | +
|
| 123 | +?> |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | $wgAutoloadClasses['MapsMapFeature'] = $egMapsIP . '/Maps_MapFeature.php'; |
36 | 36 | $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/Maps_BaseMap.php'; |
37 | 37 | $wgAutoloadClasses['MapsMapper'] = $egMapsIP . '/Maps_Mapper.php'; |
| 38 | +$wgAutoloadClasses['MapsParserFunctions'] = $egMapsIP . '/Maps_ParserFunctions.php'; |
38 | 39 | $wgAutoloadClasses['MapsUtils'] = $egMapsIP . '/Maps_Utils.php'; |
39 | 40 | $wgAutoloadClasses['MapsGeocoder'] = $egMapsIP . '/Maps_Geocoder.php'; |
40 | 41 | $wgAutoloadClasses['MapsBaseGeocoder'] = $egMapsIP . '/Maps_BaseGeocoder.php'; |
— | — | @@ -43,17 +44,25 @@ |
44 | 45 | |
45 | 46 | $egMapsServices['googlemaps'] = array( |
46 | 47 | 'pf' => array('class' => 'MapsGoogleMaps', 'file' => 'GoogleMaps/Maps_GoogleMaps.php', 'local' => true), |
| 48 | + 'classes' => array( |
| 49 | + array('class' => 'MapsGoogleMapsUtils', 'file' => 'GoogleMaps/Maps_GoogleMapsUtils.php', 'local' => true) |
| 50 | + ), |
47 | 51 | 'aliases' => array('google', 'googlemap', 'gmap', 'gmaps'), |
48 | 52 | 'parameters' => array( |
49 | 53 | 'type' => array('map-type', 'map type'), |
| 54 | + 'types' => array('map-types', 'map types'), |
50 | 55 | 'earth' => array(), |
51 | 56 | 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom'), |
52 | | - 'class' => array() |
| 57 | + 'class' => array(), |
| 58 | + 'style' => array() |
53 | 59 | ) |
54 | 60 | ); |
55 | 61 | |
56 | 62 | $egMapsServices['openlayers'] = array( |
57 | 63 | 'pf' => array('class' => 'MapsOpenLayers', 'file' => 'OpenLayers/Maps_OpenLayers.php', 'local' => true), |
| 64 | + 'classes' => array( |
| 65 | + array('class' => 'MapsOpenLayersUtils', 'file' => 'OpenLayers/Maps_OpenLayersUtils.php', 'local' => true) |
| 66 | + ), |
58 | 67 | 'aliases' => array('layers', 'openlayer'), |
59 | 68 | 'parameters' => array( |
60 | 69 | 'layers' => array(), |
— | — | @@ -63,9 +72,13 @@ |
64 | 73 | |
65 | 74 | $egMapsServices['yahoomaps'] = array( |
66 | 75 | 'pf' => array('class' => 'MapsYahooMaps', 'file' => 'YahooMaps/Maps_YahooMaps.php', 'local' => true), |
| 76 | + 'classes' => array( |
| 77 | + array('class' => 'MapsYahooMapsUtils', 'file' => 'YahooMaps/Maps_YahooMapsUtils.php', 'local' => true) |
| 78 | + ), |
67 | 79 | 'aliases' => array('yahoo', 'yahoomap', 'ymap', 'ymaps'), |
68 | 80 | 'parameters' => array( |
69 | 81 | 'type' => array('map-type'), |
| 82 | + 'types' => array('map-types', 'map types'), |
70 | 83 | 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom') |
71 | 84 | ) |
72 | 85 | ); |
— | — | @@ -104,6 +117,11 @@ |
105 | 118 | foreach ($egMapsServices as $serviceData) { |
106 | 119 | $file = $serviceData['pf']['local'] ? $egMapsIP . '/' . $serviceData['pf']['file'] : $serviceData['pf']['file']; |
107 | 120 | $wgAutoloadClasses[$serviceData['pf']['class']] = $file; |
| 121 | + |
| 122 | + foreach($serviceData['classes'] as $class) { |
| 123 | + $file = $class['local'] ? $egMapsIP . '/' . $class['file'] : $class['file']; |
| 124 | + $wgAutoloadClasses[$class['class']] = $file; |
| 125 | + } |
108 | 126 | } |
109 | 127 | } |
110 | 128 | |
— | — | @@ -114,12 +132,12 @@ |
115 | 133 | global $wgParser; |
116 | 134 | |
117 | 135 | // A hooks to enable the '#display_point' and '#display_points' parser functions |
118 | | - $wgParser->setFunctionHook( 'display_point', array('MapsMapper', 'displayPointRender' )); |
119 | | - $wgParser->setFunctionHook( 'display_points', array('MapsMapper', 'displayPointsRender' )); |
| 136 | + $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender' )); |
| 137 | + $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender' )); |
120 | 138 | |
121 | 139 | // A hooks to enable the '#display_adress' and '#display_adresses' parser functions |
122 | | - $wgParser->setFunctionHook( 'display_address', array('MapsMapper', 'displayAddressRender' )); |
123 | | - $wgParser->setFunctionHook( 'display_addresses', array('MapsMapper', 'displayAddressesRender' )); |
| 140 | + $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender' )); |
| 141 | + $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender' )); |
124 | 142 | |
125 | 143 | // A hook to enable the geocoder parser functions |
126 | 144 | $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder' )); |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * A class that holds handlers for the mapping parser functions |
| 5 | + * A class that holds static helper functions for common functionality that is not map-spesific. |
6 | 6 | * |
7 | 7 | * @file Maps_Mapper.php |
8 | 8 | * @ingroup Maps |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | */ |
49 | 49 | public static function setDefaultParValues(array $params, array $serviceDefaults, $strict = true) { |
50 | 50 | global $egMapsMapLat, $egMapsMapLon, $egMapsMapWidth, $egMapsMapHeight, $egMapsDefaultService; |
51 | | - |
| 51 | + |
52 | 52 | $mapDefaults = array( |
53 | 53 | 'service' => $egMapsDefaultService, |
54 | 54 | 'coordinates' => "$egMapsMapLat, $egMapsMapLon", |
— | — | @@ -70,45 +70,6 @@ |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | | - * Returns a valid version of the provided parameter array. Paramaters that are not allowed will |
75 | | - * be ignored, and alias parameter names will be changed to main parameter names, using getMainParamName(). |
76 | | - * |
77 | | - * @param array $params |
78 | | - * @param array $serviceParameters |
79 | | - * @return array |
80 | | - */ |
81 | | - public static function getValidParams(array $params, array $serviceParameters) { |
82 | | - $validParams = array(); |
83 | | - |
84 | | - $allowedParms = array_merge(self::$mainParams, $serviceParameters); |
85 | | - |
86 | | - foreach($params as $paramName => $paramValue) { |
87 | | - $paramName = self::getMainParamName($paramName, $allowedParms); |
88 | | - if(array_key_exists($paramName, $allowedParms)) $validParams[$paramName] = $paramValue; |
89 | | - } |
90 | | - |
91 | | - return $validParams; |
92 | | - } |
93 | | - |
94 | | - /** |
95 | | - * Checks if the patameter name is an alias for an actual parameter, |
96 | | - * and changes it into the main paremeter name if this is the case. |
97 | | - * |
98 | | - * @param string $paramName |
99 | | - * @param array $allowedParms |
100 | | - * @return string |
101 | | - */ |
102 | | - private static function getMainParamName($paramName, array $allowedParms) { |
103 | | - if (!array_key_exists($paramName, $allowedParms)) { |
104 | | - foreach ($allowedParms as $name => $aliases) { |
105 | | - if (in_array($paramName, $aliases)) $paramName = $name; |
106 | | - } |
107 | | - } |
108 | | - |
109 | | - return $paramName; |
110 | | - } |
111 | | - |
112 | | - /** |
113 | 74 | * Returns the JS version (true/false as string) of the provided boolean parameter. |
114 | 75 | * |
115 | 76 | * @param boolean $bool |
— | — | @@ -136,138 +97,60 @@ |
137 | 98 | * |
138 | 99 | * @param array $items |
139 | 100 | * @param array $defaultItems |
| 101 | + * @param boolean $asStrings |
140 | 102 | * @return string |
141 | 103 | */ |
142 | | - public static function createJSItemsString(array $items, array $defaultItems) { |
143 | | - if (count($items) < 1) $items = $defaultItems; |
144 | | - return "'" . strtolower(implode("','", $items)) . "'"; |
145 | | - } |
| 104 | + public static function createJSItemsString(array $items, array $defaultItems = null, $asStrings = true, $toLower = true) { |
| 105 | + if (count($items) < 1 && isset($defaultItems)) $items = $defaultItems; |
| 106 | + $itemString = $asStrings ? "'" . implode("','", $items) . "'" : implode(",", $items); |
| 107 | + if ($toLower) $itemString = strtolower($itemString); |
| 108 | + return $itemString; |
| 109 | + } |
146 | 110 | |
147 | 111 | /** |
148 | | - * Sets the default map properties, gets the map HTML depending |
149 | | - * on the provided service, and then returns it. |
| 112 | + * Returns a valid version of the provided parameter array. Paramaters that are not allowed will |
| 113 | + * be ignored, and alias parameter names will be changed to main parameter names, using getMainParamName(). |
150 | 114 | * |
151 | | - * @param unknown_type $parser |
| 115 | + * @param array $paramz |
| 116 | + * @param array $serviceParameters |
152 | 117 | * @return array |
153 | 118 | */ |
154 | | - public static function displayPointRender(&$parser) { |
155 | | - global $egMapsServices; |
| 119 | + public static function getValidParams(array $paramz, array $serviceParameters) { |
| 120 | + $validParams = array(); |
156 | 121 | |
157 | | - $params = func_get_args(); |
158 | | - array_shift( $params ); // We already know the $parser ... |
| 122 | + $allowedParms = array_merge(self::$mainParams, $serviceParameters); |
159 | 123 | |
160 | | - if (is_array($params[0])) $params = $params[0]; |
161 | | - |
162 | | - $map = array(); |
163 | | - |
164 | | - foreach($params as $param) { |
165 | | - $split = split('=', $param); |
166 | | - if (count($split) == 2) { |
167 | | - $paramName = strtolower(trim($split[0])); |
168 | | - $paramValue = trim($split[1]); |
169 | | - $map[$paramName] = $paramValue; |
170 | | - } |
171 | | - if (count($split) == 1) { // Default parameter (without name) |
172 | | - $map['coordinates'] = trim($split[0]); |
173 | | - } |
| 124 | + foreach($paramz as $paramName => $paramValue) { |
| 125 | + //echo "$paramName ->into-> "; |
| 126 | + $paramName = self::getMainParamName($paramName, $allowedParms); |
| 127 | + //echo "$paramName ,withval, "; var_dump($paramValue); echo " <br />\n"; |
| 128 | + if(array_key_exists($paramName, $allowedParms)) $validParams[$paramName] = $paramValue; |
174 | 129 | } |
175 | 130 | |
176 | | - $map['coordinates'] = explode(';', $map['coordinates']); |
177 | | - |
178 | | - $map['service'] = self::getValidService($map['service']); |
179 | | - |
180 | | - $map = self::setDefaultParValues($map, $egMapsServices[$map['service']]['parameters'], true); |
181 | | - |
182 | | - $mapClass = new $egMapsServices[$map['service']]['pf']['class'](); |
183 | | - |
184 | | - // Call the function according to the map service to get the HTML output |
185 | | - $output = $mapClass->displayMap($parser, $map); |
186 | | - |
187 | | - // Return the result |
188 | | - return array( $output, 'noparse' => true, 'isHTML' => true ); |
| 131 | + return $validParams; |
189 | 132 | } |
190 | | - |
191 | | - /** |
192 | | - * Sets the default map properties, gets the map HTML depending |
193 | | - * on the provided service, and then returns it. |
194 | | - * |
195 | | - * @param unknown_type $parser |
196 | | - */ |
197 | | - public static function displayPointsRender(&$parser) { |
198 | | - $params = func_get_args(); |
199 | | - array_shift( $params ); // We already know the $parser ... |
200 | | - |
201 | | - return self::displayPointRender($parser, $params); |
202 | | - } |
203 | 133 | |
204 | 134 | /** |
205 | | - * Turns the address parameter into coordinates, then lets |
206 | | - * @see MapsMapper::displayPointRender() do the work and returns it. |
| 135 | + * Checks if the patameter name is an alias for an actual parameter, |
| 136 | + * and changes it into the main paremeter name if this is the case. |
207 | 137 | * |
208 | | - * @param unknown_type $parser |
209 | | - * @return array |
| 138 | + * @param string $paramName |
| 139 | + * @param array $allowedParms |
| 140 | + * @return string |
210 | 141 | */ |
211 | | - public static function displayAddressRender(&$parser) { |
212 | | - global $egMapsDefaultService; |
213 | | - |
214 | | - $params = func_get_args(); |
215 | | - array_shift( $params ); // We already know the $parser ... |
216 | | - |
217 | | - self::changeAddressToCoords($params); |
218 | | - |
219 | | - return self::displayPointRender($parser, $params); |
220 | | - } |
221 | | - |
222 | | - /** |
223 | | - * Turns the address parameter into coordinates, then lets |
224 | | - * @see MapsMapper::displayPointRender() do the work and returns it. |
225 | | - * |
226 | | - * @param unknown_type $parser |
227 | | - */ |
228 | | - public static function displayAddressesRender(&$parser) { |
229 | | - return self::displayAddressRender(func_get_args()); |
230 | | - } |
231 | | - |
232 | | - /** |
233 | | - * Changes the values of the address or addresses parameter into coordinates |
234 | | - * in the provided array. |
235 | | - * |
236 | | - * @param array $params |
237 | | - */ |
238 | | - private static function changeAddressToCoords(&$params) { |
239 | | - global $egMapsDefaultService; |
240 | | - |
241 | | - for ($i = 0; $i < count($params); $i++) { |
242 | | - $split = split('=', $params[$i]); |
243 | | - if (strtolower(trim($split[0])) == 'service' && count($split) > 1) { |
244 | | - $service = trim($split[1]); |
| 142 | + private static function getMainParamName($paramName, array $allowedParms) { |
| 143 | + //echo "$paramName -> "; |
| 144 | + if (!array_key_exists($paramName, $allowedParms)) { |
| 145 | + foreach ($allowedParms as $name => $aliases) { |
| 146 | + if (in_array($paramName, $aliases)) { |
| 147 | + $paramName = $name; |
| 148 | + } |
245 | 149 | } |
246 | | - else if (strtolower(trim($split[0])) == 'geoservice' && count($split) > 1) { |
247 | | - $geoservice = trim($split[1]); |
248 | | - } |
249 | 150 | } |
250 | | - |
251 | | - $service = isset($service) ? MapsMapper::getValidService($service) : $egMapsDefaultService; |
252 | | - $geoservice = isset($geoservice) ? $geoservice : ''; |
| 151 | + //echo "$paramName<br />"; |
| 152 | + return $paramName; |
| 153 | + } |
253 | 154 | |
254 | | - for ($i = 0; $i < count($params); $i++) { |
255 | | - $split = split('=', $params[$i]); |
256 | | - if (((strtolower(trim($split[0])) == 'address' || strtolower(trim($split[0])) == 'addresses') && count($split) > 1) || count($split) == 1) { |
257 | | - $address_srting = count($split) == 1 ? $split[0] : $split[1]; |
258 | | - |
259 | | - $addresses = explode(';', $address_srting); |
260 | | - |
261 | | - $coordinates = array(); |
262 | | - |
263 | | - foreach($addresses as $address) { |
264 | | - $coordinates[] = MapsGeocoder::renderGeocoder(null, trim($address), $geoservice, $service); |
265 | | - } |
266 | | - |
267 | | - $params[$i] = 'coordinates=' . implode(';', $coordinates); |
268 | | - } |
269 | | - } |
270 | | - } |
271 | | - |
272 | 155 | /** |
273 | 156 | * Returns a valid service. When an invalid service is provided, the default one will be returned. |
274 | 157 | * Aliases are also chancged into the main service names @see MapsMapper::getMainServiceName(). |
Index: trunk/extensions/Maps/Maps_ParserFunctions.php |
— | — | @@ -0,0 +1,145 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * A class that holds handlers for the mapping parser functions.
|
| 6 | + * Spesific functions are located in @see MapsUtils
|
| 7 | + *
|
| 8 | + * @file Maps_ParserFunctions.php
|
| 9 | + * @ingroup Maps
|
| 10 | + *
|
| 11 | + * @author Jeroen De Dauw
|
| 12 | + */
|
| 13 | +
|
| 14 | +if( !defined( 'MEDIAWIKI' ) ) {
|
| 15 | + die( 'Not an entry point.' );
|
| 16 | +}
|
| 17 | +
|
| 18 | +final class MapsParserFunctions {
|
| 19 | +
|
| 20 | + /**
|
| 21 | + * Sets the default map properties, gets the map HTML depending
|
| 22 | + * on the provided service, and then returns it.
|
| 23 | + *
|
| 24 | + * @param unknown_type $parser
|
| 25 | + * @return array
|
| 26 | + */
|
| 27 | + public static function displayPointRender(&$parser) {
|
| 28 | + global $egMapsServices;
|
| 29 | +
|
| 30 | + $params = func_get_args();
|
| 31 | + array_shift( $params ); // We already know the $parser ...
|
| 32 | +
|
| 33 | + if (is_array($params[0])) $params = $params[0];
|
| 34 | +
|
| 35 | + $map = array();
|
| 36 | +
|
| 37 | + foreach($params as $param) {
|
| 38 | + $split = split('=', $param);
|
| 39 | + if (count($split) == 2) {
|
| 40 | + $paramName = strtolower(trim($split[0]));
|
| 41 | + $paramValue = trim($split[1]);
|
| 42 | + $map[$paramName] = $paramValue;
|
| 43 | + }
|
| 44 | + if (count($split) == 1) { // Default parameter (without name)
|
| 45 | + $map['coordinates'] = trim($split[0]);
|
| 46 | + }
|
| 47 | + }
|
| 48 | +
|
| 49 | + $map['service'] = MapsMapper::getValidService($map['service']);
|
| 50 | +
|
| 51 | + $mapClass = new $egMapsServices[$map['service']]['pf']['class']();
|
| 52 | +
|
| 53 | + // Call the function according to the map service to get the HTML output
|
| 54 | + $output = $mapClass->displayMap($parser, $map);
|
| 55 | +
|
| 56 | + // Return the result
|
| 57 | + return array( $output, 'noparse' => true, 'isHTML' => true );
|
| 58 | + }
|
| 59 | +
|
| 60 | + /**
|
| 61 | + * Sets the default map properties, gets the map HTML depending
|
| 62 | + * on the provided service, and then returns it.
|
| 63 | + *
|
| 64 | + * @param unknown_type $parser
|
| 65 | + */
|
| 66 | + public static function displayPointsRender(&$parser) {
|
| 67 | + $params = func_get_args();
|
| 68 | + array_shift( $params ); // We already know the $parser ...
|
| 69 | +
|
| 70 | + if (is_array($params[0])) $params = $params[0];
|
| 71 | +
|
| 72 | + return self::displayPointRender($parser, $params);
|
| 73 | + }
|
| 74 | +
|
| 75 | + /**
|
| 76 | + * Turns the address parameter into coordinates, then lets
|
| 77 | + * @see MapsMapper::displayPointRender() do the work and returns it.
|
| 78 | + *
|
| 79 | + * @param unknown_type $parser
|
| 80 | + * @return array
|
| 81 | + */
|
| 82 | + public static function displayAddressRender(&$parser) {
|
| 83 | + $params = func_get_args();
|
| 84 | + array_shift( $params ); // We already know the $parser ...
|
| 85 | +
|
| 86 | + self::changeAddressToCoords($params);
|
| 87 | +
|
| 88 | + return self::displayPointRender($parser, $params);
|
| 89 | + }
|
| 90 | +
|
| 91 | + /**
|
| 92 | + * Turns the address parameter into coordinates, then lets
|
| 93 | + * @see MapsMapper::displayPointRender() do the work and returns it.
|
| 94 | + *
|
| 95 | + * @param unknown_type $parser
|
| 96 | + */
|
| 97 | + public static function displayAddressesRender(&$parser) {
|
| 98 | + $params = func_get_args();
|
| 99 | + array_shift( $params ); // We already know the $parser ...
|
| 100 | +
|
| 101 | + self::changeAddressToCoords($params);
|
| 102 | +
|
| 103 | + return self::displayPointsRender($parser, $params);
|
| 104 | + }
|
| 105 | +
|
| 106 | + /**
|
| 107 | + * Changes the values of the address or addresses parameter into coordinates
|
| 108 | + * in the provided array.
|
| 109 | + *
|
| 110 | + * @param array $params
|
| 111 | + */
|
| 112 | + private static function changeAddressToCoords(&$params) {
|
| 113 | + global $egMapsDefaultService;
|
| 114 | +
|
| 115 | + for ($i = 0; $i < count($params); $i++) {
|
| 116 | + $split = split('=', $params[$i]);
|
| 117 | + if (strtolower(trim($split[0])) == 'service' && count($split) > 1) {
|
| 118 | + $service = trim($split[1]);
|
| 119 | + }
|
| 120 | + else if (strtolower(trim($split[0])) == 'geoservice' && count($split) > 1) {
|
| 121 | + $geoservice = trim($split[1]);
|
| 122 | + }
|
| 123 | + }
|
| 124 | +
|
| 125 | + $service = isset($service) ? MapsMapper::getValidService($service) : $egMapsDefaultService;
|
| 126 | + $geoservice = isset($geoservice) ? $geoservice : '';
|
| 127 | +
|
| 128 | + for ($i = 0; $i < count($params); $i++) {
|
| 129 | + $split = split('=', $params[$i]);
|
| 130 | + if (((strtolower(trim($split[0])) == 'address' || strtolower(trim($split[0])) == 'addresses') && count($split) > 1) || count($split) == 1) {
|
| 131 | + $address_srting = count($split) == 1 ? $split[0] : $split[1];
|
| 132 | +
|
| 133 | + $addresses = explode(';', $address_srting);
|
| 134 | +
|
| 135 | + $coordinates = array();
|
| 136 | +
|
| 137 | + foreach($addresses as $address) {
|
| 138 | + $coordinates[] = MapsGeocoder::renderGeocoder(null, trim($address), $geoservice, $service);
|
| 139 | + }
|
| 140 | +
|
| 141 | + $params[$i] = 'coordinates=' . implode(';', $coordinates);
|
| 142 | + }
|
| 143 | + }
|
| 144 | + }
|
| 145 | +
|
| 146 | +} |
\ No newline at end of file |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | -* Form input hook that adds an Google Maps map format to Semantic Forms |
| 5 | + * Class for handling the Maps parser functions with Google Maps |
5 | 6 | * |
6 | 7 | * @file Maps_GoogleMaps.php |
7 | 8 | * @ingroup Maps |
— | — | @@ -18,115 +19,15 @@ |
19 | 20 | |
20 | 21 | public $serviceName = self::SERVICE_NAME; |
21 | 22 | |
22 | | - // http://code.google.com/apis/maps/documentation/introduction.html#MapTypes |
23 | | - private static $mapTypes = array( |
24 | | - 'normal' => 'G_NORMAL_MAP', |
25 | | - 'satellite' => 'G_SATELLITE_MAP', |
26 | | - 'hybrid' => 'G_HYBRID_MAP', |
27 | | - 'physical' => 'G_PHYSICAL_MAP', |
28 | | - 'earth' => 'G_SATELLITE_3D_MAP', |
29 | | - ); |
30 | | - |
31 | | - // http://code.google.com/apis/maps/documentation/controls.html#Controls_overview |
32 | | - private static $controlClasses = array( |
33 | | - 'large' => 'GLargeMapControl3D', |
34 | | - 'small' => 'GSmallZoomControl3D', |
35 | | - ); |
36 | | - |
37 | 23 | /** |
38 | | - * Returns the Google Map type (defined in MapsGoogleMaps::$mapTypes) |
39 | | - * for the provided a general map type. When no match is found, the first |
40 | | - * possible Google Map type will be returned as default. |
41 | | - * |
42 | | - * @param string $type |
43 | | - * @param boolean $earthEnabled |
44 | | - * @return string |
45 | | - */ |
46 | | - public static function getGMapType($type, $earthEnabled = false) { |
47 | | - global $egMapsGoogleMapsType; |
48 | | - |
49 | | - if (! array_key_exists($type, MapsGoogleMaps::$mapTypes)) { |
50 | | - $type = $earthEnabled ? "earth" : $egMapsGoogleMapsType;; |
51 | | - } |
52 | | - |
53 | | - return self::$mapTypes[ $type ]; |
54 | | - } |
55 | | - |
56 | | - /** |
57 | | - * Returns the Google Map Control type (defined in MapsGoogleMaps::$controlClasses) |
58 | | - * for the provided a general map control type. When no match is found, the provided |
59 | | - * control name will be used. |
60 | | - * |
61 | | - * @param array $controls |
62 | | - * @return string |
63 | | - */ |
64 | | - public static function getGControlType(array $controls) { |
65 | | - global $egMapsGMapControl; |
66 | | - $control = count($controls) > 0 ? $controls[0] : $egMapsGMapControl; |
67 | | - return array_key_exists($control, MapsGoogleMaps::$controlClasses) ? MapsGoogleMaps::$controlClasses[$control] : $control; |
68 | | - } |
69 | | - |
70 | | - /** |
71 | | - * Retuns an array holding the default parameters and their values. |
72 | | - * |
73 | | - * @return array |
74 | | - */ |
75 | | - public static function getDefaultParams() { |
76 | | - return array |
77 | | - ( |
78 | | - 'type' => '', |
79 | | - 'class' => 'pmap', |
80 | | - 'autozoom' => '', |
81 | | - 'earth' => '' |
82 | | - ); |
83 | | - } |
84 | | - |
85 | | - /** |
86 | | - * Add references to the Google Maps API and required JS file to the provided output |
87 | | - * |
88 | | - * @param unknown_type $output |
89 | | - */ |
90 | | - public static function addGMapDependencies(&$output) { |
91 | | - global $wgJsMimeType, $wgLang; |
92 | | - global $egGoogleMapsKey, $egMapsIncludePath, $egGoogleMapsOnThisPage; |
93 | | - |
94 | | - if (empty($egGoogleMapsOnThisPage)) { |
95 | | - |
96 | | - $egGoogleMapsOnThisPage = 0; |
97 | | - $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script> |
98 | | - <script type='$wgJsMimeType' src='$egMapsIncludePath/GoogleMaps/GoogleMapFunctions.js'></script>"; |
99 | | - } |
100 | | - } |
101 | | - |
102 | | - /** |
103 | | - * Retuns a boolean as string, true if $autozoom is on or yes. |
104 | | - * |
105 | | - * @param string $autozoom |
106 | | - * @return string |
107 | | - */ |
108 | | - public static function getAutozoomJSValue($autozoom) { |
109 | | - return MapsMapper::getJSBoolValue(in_array($autozoom, array('on', 'yes'))); |
110 | | - } |
111 | | - |
112 | | - /** |
113 | | - * Returns a boolean representing if the earth map type should be showed or not, |
114 | | - * when provided the the wiki code value. |
115 | | - * |
116 | | - * @param string $earthValue |
117 | | - * @return boolean Indicates wether the earth type should be enabled. |
118 | | - */ |
119 | | - public static function getEarthValue($earthValue) { |
120 | | - $trueValues = array('on', 'yes'); |
121 | | - return in_array($earthValue, $trueValues); |
122 | | - } |
123 | | - |
124 | | - /** |
125 | 24 | * @see MapsBaseMap::setFormInputSettings() |
126 | 25 | * |
127 | 26 | */ |
128 | 27 | protected function setMapSettings() { |
129 | 28 | global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix; |
130 | 29 | |
| 30 | + $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams(); |
| 31 | + |
131 | 32 | $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
132 | 33 | $this->defaultZoom = $egMapsGoogleMapsZoom; |
133 | 34 | } |
— | — | @@ -138,7 +39,7 @@ |
139 | 40 | protected function doMapServiceLoad() { |
140 | 41 | global $egGoogleMapsOnThisPage; |
141 | 42 | |
142 | | - self::addGMapDependencies($this->output); |
| 43 | + MapsGoogleMapsUtils::addGMapDependencies($this->output); |
143 | 44 | $egGoogleMapsOnThisPage++; |
144 | 45 | |
145 | 46 | $this->elementNr = $egGoogleMapsOnThisPage; |
— | — | @@ -150,14 +51,15 @@ |
151 | 52 | */ |
152 | 53 | public function addSpecificMapHTML() { |
153 | 54 | global $wgJsMimeType; |
| 55 | + global $egMapsGoogleMapsTypes; |
154 | 56 | |
155 | | - $enableEarth = self::getEarthValue($this->earth); |
| 57 | + $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth); |
156 | 58 | $this->earth = MapsMapper::getJSBoolValue($enableEarth); |
157 | 59 | |
158 | | - $this->type = self::getGMapType($this->type, $enableEarth); |
159 | | - $control = self::getGControlType($this->controls); |
| 60 | + $this->type = MapsGoogleMapsUtils::getGMapType($this->type, $enableEarth); |
| 61 | + $control = MapsGoogleMapsUtils::getGControlType($this->controls); |
160 | 62 | |
161 | | - $this->autozoom = self::getAutozoomJSValue($this->autozoom); |
| 63 | + $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom); |
162 | 64 | |
163 | 65 | $markerItems = array(); |
164 | 66 | |
— | — | @@ -170,12 +72,25 @@ |
171 | 73 | |
172 | 74 | $markersString = implode(',', $markerItems); |
173 | 75 | |
| 76 | + $this->types = explode(",", $this->types); |
| 77 | + |
| 78 | + if (count($this->types) < 1) $this->types = $egMapsGoogleMapsTypes; |
| 79 | + |
| 80 | + for($i = 0 ; $i < count($this->types); $i++) { |
| 81 | + $this->types[$i] = MapsGoogleMapsUtils::getGMapType($this->types[$i], $enableEarth); |
| 82 | + } |
| 83 | + |
| 84 | + // This is to ensure backwards compatibility with 0.1 and 0.2. |
| 85 | + if ($enableEarth && ! in_array('G_SATELLITE_3D_MAP', $this->types)) $this->types[] = 'G_SATELLITE_3D_MAP'; |
| 86 | + |
| 87 | + $typesString = MapsMapper::createJSItemsString($this->types, null, false, false); |
| 88 | + |
174 | 89 | $this->output .=<<<END |
175 | 90 | |
176 | 91 | <div id="$this->mapName" class="$this->class" style="$this->style" ></div> |
177 | 92 | <script type="$wgJsMimeType"> /*<![CDATA[*/ |
178 | 93 | addLoadEvent( |
179 | | - initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, new $control(), $this->autozoom, $this->earth, [$markersString]) |
| 94 | + initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], new $control(), $this->autozoom, $this->earth, [$markersString]) |
180 | 95 | ); |
181 | 96 | /*]]>*/ </script> |
182 | 97 | |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php |
— | — | @@ -0,0 +1,151 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * A class that holds static helper functions for Google Maps
|
| 6 | + *
|
| 7 | + * @file Maps_GooleMapsUtils.php
|
| 8 | + * @ingroup Maps
|
| 9 | + *
|
| 10 | + * @author Jeroen De Dauw
|
| 11 | + */
|
| 12 | +
|
| 13 | +if( !defined( 'MEDIAWIKI' ) ) {
|
| 14 | + die( 'Not an entry point.' );
|
| 15 | +}
|
| 16 | +
|
| 17 | +final class MapsGoogleMapsUtils {
|
| 18 | +
|
| 19 | + // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP
|
| 20 | + // TODO: Add a true alliasing system? Might be overkill.
|
| 21 | + private static $mapTypes = array(
|
| 22 | + 'normal' => 'G_NORMAL_MAP',
|
| 23 | + 'G_NORMAL_MAP' => 'G_NORMAL_MAP',
|
| 24 | +
|
| 25 | + 'satellite' => 'G_SATELLITE_MAP',
|
| 26 | + 'G_SATELLITE_MAP' => 'G_SATELLITE_MAP',
|
| 27 | +
|
| 28 | + 'hybrid' => 'G_HYBRID_MAP',
|
| 29 | + 'G_HYBRID_MAP' => 'G_HYBRID_MAP',
|
| 30 | +
|
| 31 | + 'physical' => 'G_PHYSICAL_MAP',
|
| 32 | + 'G_PHYSICAL_MAP' => 'G_PHYSICAL_MAP',
|
| 33 | +
|
| 34 | + 'earth' => 'G_SATELLITE_3D_MAP',
|
| 35 | + 'G_SATELLITE_3D_MAP' => 'G_SATELLITE_3D_MAP',
|
| 36 | +
|
| 37 | + 'sky' => 'G_SKY_VISIBLE_MAP',
|
| 38 | + 'G_SKY_VISIBLE_MAP' => 'G_SKY_VISIBLE_MAP',
|
| 39 | +
|
| 40 | + 'moon' => 'G_MOON_VISIBLE_MAP',
|
| 41 | + 'G_MOON_VISIBLE_MAP' => 'G_MOON_VISIBLE_MAP',
|
| 42 | +
|
| 43 | + 'moon-elevation' => 'G_MOON_ELEVATION_MAP',
|
| 44 | + 'G_MOON_ELEVATION_MAP' => 'G_MOON_ELEVATION_MAP',
|
| 45 | +
|
| 46 | + 'mars' => 'G_MARS_VISIBLE_MAP',
|
| 47 | + 'G_MARS_VISIBLE_MAP' => 'G_MARS_VISIBLE_MAP',
|
| 48 | +
|
| 49 | + 'mars-elevation' => 'G_MARS_ELEVATION_MAP',
|
| 50 | + 'G_MARS_ELEVATION_MAP' => 'G_MARS_ELEVATION_MAP',
|
| 51 | +
|
| 52 | + 'mars-infrared' => 'G_MARS_INFRARED_MAP',
|
| 53 | + 'G_MARS_INFRARED_MAP' => 'G_MARS_INFRARED_MAP',
|
| 54 | + );
|
| 55 | +
|
| 56 | + // http://code.google.com/apis/maps/documentation/controls.html#Controls_overview
|
| 57 | + private static $controlClasses = array(
|
| 58 | + 'large' => 'GLargeMapControl3D',
|
| 59 | + 'small' => 'GSmallZoomControl3D',
|
| 60 | + );
|
| 61 | +
|
| 62 | + /**
|
| 63 | + * Returns the Google Map type (defined in MapsGoogleMaps::$mapTypes)
|
| 64 | + * for the provided a general map type. When no match is found, the
|
| 65 | + * default map type will be returned.
|
| 66 | + *
|
| 67 | + * @param string $type
|
| 68 | + * @param boolean $earthEnabled
|
| 69 | + * @return string
|
| 70 | + */
|
| 71 | + public static function getGMapType($type, $earthEnabled = false) {
|
| 72 | + global $egMapsGoogleMapsType;
|
| 73 | +
|
| 74 | + if (! array_key_exists($type, self::$mapTypes)) {
|
| 75 | + $type = $earthEnabled ? "earth" : $egMapsGoogleMapsType;
|
| 76 | + }
|
| 77 | +
|
| 78 | + return self::$mapTypes[ $type ];
|
| 79 | + }
|
| 80 | +
|
| 81 | + /**
|
| 82 | + * Returns the Google Map Control type (defined in MapsGoogleMaps::$controlClasses)
|
| 83 | + * for the provided a general map control type. When no match is found, the provided
|
| 84 | + * control name will be used.
|
| 85 | + *
|
| 86 | + * @param array $controls
|
| 87 | + * @return string
|
| 88 | + */
|
| 89 | + public static function getGControlType(array $controls) {
|
| 90 | + global $egMapsGMapControl;
|
| 91 | + $control = count($controls) > 0 ? $controls[0] : $egMapsGMapControl;
|
| 92 | + return array_key_exists($control, self::$controlClasses) ? self::$controlClasses[$control] : $control;
|
| 93 | + }
|
| 94 | +
|
| 95 | + /**
|
| 96 | + * Retuns an array holding the default parameters and their values.
|
| 97 | + *
|
| 98 | + * @return array
|
| 99 | + */
|
| 100 | + public static function getDefaultParams() {
|
| 101 | + return array
|
| 102 | + (
|
| 103 | + 'type' => '',
|
| 104 | + 'types' => array(),
|
| 105 | + 'class' => 'pmap',
|
| 106 | + 'autozoom' => '',
|
| 107 | + 'earth' => '',
|
| 108 | + 'style' => ''
|
| 109 | + );
|
| 110 | + }
|
| 111 | +
|
| 112 | + /**
|
| 113 | + * Add references to the Google Maps API and required JS file to the provided output
|
| 114 | + *
|
| 115 | + * @param unknown_type $output
|
| 116 | + */
|
| 117 | + public static function addGMapDependencies(&$output) {
|
| 118 | + global $wgJsMimeType, $wgLang;
|
| 119 | + global $egGoogleMapsKey, $egMapsIncludePath, $egGoogleMapsOnThisPage;
|
| 120 | +
|
| 121 | + if (empty($egGoogleMapsOnThisPage)) {
|
| 122 | +
|
| 123 | + $egGoogleMapsOnThisPage = 0;
|
| 124 | + $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script>
|
| 125 | + <script type='$wgJsMimeType' src='$egMapsIncludePath/GoogleMaps/GoogleMapFunctions.js'></script>";
|
| 126 | + }
|
| 127 | + }
|
| 128 | +
|
| 129 | + /**
|
| 130 | + * Retuns a boolean as string, true if $autozoom is on or yes.
|
| 131 | + *
|
| 132 | + * @param string $autozoom
|
| 133 | + * @return string
|
| 134 | + */
|
| 135 | + public static function getAutozoomJSValue($autozoom) {
|
| 136 | + return MapsMapper::getJSBoolValue(in_array($autozoom, array('on', 'yes')));
|
| 137 | + }
|
| 138 | +
|
| 139 | + /**
|
| 140 | + * Returns a boolean representing if the earth map type should be showed or not,
|
| 141 | + * when provided the the wiki code value.
|
| 142 | + *
|
| 143 | + * @param string $earthValue
|
| 144 | + * @return boolean Indicates wether the earth type should be enabled.
|
| 145 | + */
|
| 146 | + public static function getEarthValue($earthValue) {
|
| 147 | + $trueValues = array('on', 'yes');
|
| 148 | + return in_array($earthValue, $trueValues);
|
| 149 | + }
|
| 150 | +
|
| 151 | +
|
| 152 | +} |
\ No newline at end of file |
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -11,8 +11,8 @@ |
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | | - * Returns GMarker object on the provided location. |
16 | | - * It will show a popup baloon with title and label when clicked, if either of these is set. |
| 15 | + * Returns GMarker object on the provided location. It will show a popup baloon |
| 16 | + * with title and label when clicked, if either of these is set. |
17 | 17 | */ |
18 | 18 | function createGMarker(point, title, label, icon) { |
19 | 19 | var marker; |
— | — | @@ -42,31 +42,38 @@ |
43 | 43 | /** |
44 | 44 | * Returns GMap2 object with the provided properties and markers. |
45 | 45 | */ |
46 | | -function initializeGoogleMap(mapName, width, height, lat, lon, zoom, type, control, scrollWheelZoom, earthEnabled, markers) { |
| 46 | +function initializeGoogleMap(mapName, width, height, lat, lon, zoom, type, types, control, scrollWheelZoom, earthEnabled, markers) { |
47 | 47 | var map; |
48 | 48 | |
49 | 49 | var centre = (lat != null && lon != null) ? new GLatLng(lat, lon) : null; |
50 | 50 | |
51 | 51 | if (GBrowserIsCompatible()) { |
52 | | - map = createGoogleMap(document.getElementById(mapName), new GSize(width, height), centre, zoom, type, control, scrollWheelZoom, earthEnabled, markers); |
| 52 | + map = createGoogleMap(document.getElementById(mapName), new GSize(width, height), centre, zoom, type, types, control, scrollWheelZoom, earthEnabled, markers); |
53 | 53 | } |
54 | | - |
| 54 | + |
55 | 55 | return map; |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Returns GMap2 object with the provided properties. |
60 | 60 | */ |
61 | | -function createGoogleMap(mapElement, size, centre, zoom, type, control, scrollWheelZoom, earthEnabled, markers) { |
62 | | - var map = new GMap2(mapElement, {size: size}); |
| 61 | +function createGoogleMap(mapElement, size, centre, zoom, type, types, control, scrollWheelZoom, earthEnabled, markers) { |
| 62 | + var typesContainType = false; |
| 63 | + |
| 64 | + for (var i = 0; i < types.length; i++) { |
| 65 | + if (types[i] == type) typesContainType = true; |
| 66 | + } |
63 | 67 | |
64 | | - if (earthEnabled) map.addMapType(G_SATELLITE_3D_MAP); |
65 | | - map.addMapType(type); |
| 68 | + if (! typesContainType) types.push(type); |
66 | 69 | |
| 70 | + // TODO: Change labels of the moon/mars map types? |
| 71 | + |
| 72 | + var map = new GMap2(mapElement, {size: size, mapTypes: types}); |
| 73 | + |
67 | 74 | map.setMapType(type); |
68 | 75 | |
69 | 76 | var bounds = ((zoom == null || centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
70 | | - |
| 77 | + |
71 | 78 | for (i in markers) { |
72 | 79 | var marker = markers[i]; |
73 | 80 | map.addOverlay(createGMarker(marker.point, marker.title, marker.label, marker.icon)); |
— | — | @@ -76,7 +83,7 @@ |
77 | 84 | if (bounds != null) { |
78 | 85 | map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); |
79 | 86 | } |
80 | | - |
| 87 | + |
81 | 88 | if (centre != null) map.setCenter(centre); |
82 | 89 | if (zoom != null) map.setZoom(zoom); |
83 | 90 | |
— | — | @@ -85,6 +92,8 @@ |
86 | 93 | if (typeof(control) != 'undefined') map.addControl(control); |
87 | 94 | if (scrollWheelZoom) map.enableScrollWheelZoom(); |
88 | 95 | |
| 96 | + map.enableContinuousZoom(); |
| 97 | + |
89 | 98 | return map; |
90 | 99 | } |
91 | 100 | |
Index: trunk/extensions/Maps/Maps_MapFeature.php |
— | — | @@ -60,6 +60,8 @@ |
61 | 61 | $mapProperties = MapsMapper::getValidParams($mapProperties, $egMapsServices[$this->serviceName]['parameters']);
|
62 | 62 | $mapProperties = MapsMapper::setDefaultParValues($mapProperties, $this->defaultParams);
|
63 | 63 |
|
| 64 | + $mapProperties['coordinates'] = explode(';', $mapProperties['coordinates']);
|
| 65 | +
|
64 | 66 | // Go through the array with map parameters and create new variables
|
65 | 67 | // with the name of the key and value of the item if they don't exist on class level yet.
|
66 | 68 | foreach($mapProperties as $paramName => $paramValue) {
|
— | — | @@ -67,7 +69,7 @@ |
68 | 70 | $this->{$paramName} = $paramValue;
|
69 | 71 | }
|
70 | 72 | }
|
71 | | -
|
| 73 | +
|
72 | 74 | MapsMapper::enforceArrayValues($this->controls);
|
73 | 75 | }
|
74 | 76 |
|
Index: trunk/extensions/Maps/YahooMaps/YahooMapFunctions.js |
— | — | @@ -31,31 +31,43 @@ |
32 | 32 | /** |
33 | 33 | * Returns YMap object with the provided properties and markers. |
34 | 34 | */ |
35 | | -function initializeYahooMap(mapName, lat, lon, zoom, type, controls, scrollWheelZoom, markers) { |
| 35 | +function initializeYahooMap(mapName, lat, lon, zoom, type, types, controls, scrollWheelZoom, markers) { |
36 | 36 | var centre = (lon != null && lat != null) ? new YGeoPoint(lat, lon) : null; |
37 | | - return createYahooMap(document.getElementById(mapName), centre, zoom, type, controls, scrollWheelZoom, markers); |
| 37 | + return createYahooMap(document.getElementById(mapName), centre, zoom, type, types, controls, scrollWheelZoom, markers); |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Returns YMap object with the provided properties. |
42 | 42 | */ |
43 | | -function createYahooMap(mapElement, centre, zoom, type, controls, scrollWheelZoom, markers) { |
44 | | - var map = new YMap(mapElement); |
| 43 | +function createYahooMap(mapElement, centre, zoom, type, types controls, scrollWheelZoom, markers) { |
| 44 | + var typesContainType = false; |
| 45 | + |
| 46 | + for (var i = 0; i < types.length; i++) { |
| 47 | + if (types[i] == type) typesContainType = true; |
| 48 | + } |
45 | 49 | |
46 | | - map.addTypeControl(); |
| 50 | + if (! typesContainType) types.push(type); |
| 51 | + |
| 52 | + var map = new YMap(mapElement, type); |
47 | 53 | |
48 | 54 | for (i in controls){ |
49 | 55 | switch (controls[i]) { |
| 56 | + case 'type' : |
| 57 | + map.addTypeControl(types); |
| 58 | + break; |
50 | 59 | case 'pan' : |
51 | 60 | map.addPanControl(); |
52 | 61 | break; |
53 | 62 | case 'zoom' : |
54 | 63 | map.addZoomLong(); |
55 | | - break; |
| 64 | + break; |
| 65 | + case 'short' : |
| 66 | + map.addZoomShort(); |
| 67 | + break; |
56 | 68 | } |
57 | 69 | } |
58 | 70 | |
59 | | - map.setMapType(type); |
| 71 | + map.setMapType(); |
60 | 72 | |
61 | 73 | if (!scrollWheelZoom) map.disableKeyControls(); |
62 | 74 | |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * A class that holds static helper functions for Yahoo! Maps |
| 5 | + * Class for handling the Maps parser functions with Yahoo! Maps |
5 | 6 | * |
6 | 7 | * @file Maps_YahooMaps.php |
7 | 8 | * @ingroup Maps |
— | — | @@ -18,84 +19,15 @@ |
19 | 20 | |
20 | 21 | public $serviceName = self::SERVICE_NAME; |
21 | 22 | |
22 | | - // http://developer.yahoo.com/maps/ajax |
23 | | - private static $mapTypes = array( |
24 | | - 'normal' => 'YAHOO_MAP_REG', |
25 | | - 'satellite' => 'YAHOO_MAP_SAT', |
26 | | - 'hybrid' => 'YAHOO_MAP_HYB' |
27 | | - ); |
28 | | - |
29 | 23 | /** |
30 | | - * Returns the Yahoo Map type (defined in MapsYahooMaps::$mapTypes) |
31 | | - * for the provided a general map type. When no match is found, the first |
32 | | - * Google Map type will be returned as default. |
33 | | - * |
34 | | - * @param string $type |
35 | | - * @return string |
36 | | - */ |
37 | | - public static function getYMapType($type) { |
38 | | - global $egMapsYahooMapsType; |
39 | | - if (! array_key_exists($type, MapsYahooMaps::$mapTypes)) $type = $egMapsYahooMapsType; |
40 | | - return MapsYahooMaps::$mapTypes[ $type ]; |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * Build up a csv string with the controls, to be outputted as a JS array |
45 | | - * |
46 | | - * @param array $controls |
47 | | - * @return csv string |
48 | | - */ |
49 | | - public static function createControlsString(array $controls) { |
50 | | - global $egMapsYMapControls; |
51 | | - return MapsMapper::createJSItemsString($controls, $egMapsYMapControls); |
52 | | - } |
53 | | - |
54 | | - /** |
55 | | - * Retuns an array holding the default parameters and their values. |
56 | | - * |
57 | | - * @return array |
58 | | - */ |
59 | | - public static function getDefaultParams() { |
60 | | - return array |
61 | | - ( |
62 | | - 'type' => '', |
63 | | - 'autozoom' => '', |
64 | | - ); |
65 | | - } |
66 | | - |
67 | | - /** |
68 | | - * Add references to the Yahoo! Maps API and required JS file to the provided output |
69 | | - * |
70 | | - * @param string $output |
71 | | - */ |
72 | | - public static function addYMapDependencies(&$output) { |
73 | | - global $wgJsMimeType; |
74 | | - global $egYahooMapsKey, $egMapsIncludePath, $egYahooMapsOnThisPage; |
75 | | - |
76 | | - if (empty($egYahooMapsOnThisPage)) { |
77 | | - $egYahooMapsOnThisPage = 0; |
78 | | - $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script> |
79 | | - <script type='$wgJsMimeType' src='$egMapsIncludePath/YahooMaps/YahooMapFunctions.js'></script>"; |
80 | | - } |
81 | | - } |
82 | | - |
83 | | - /** |
84 | | - * Retuns a boolean as string, true if $autozoom is on or yes. |
85 | | - * |
86 | | - * @param string $autozoom |
87 | | - * @return string |
88 | | - */ |
89 | | - public static function getAutozoomJSValue($autozoom) { |
90 | | - return MapsMapper::getJSBoolValue(in_array($autozoom, array('on', 'yes'))); |
91 | | - } |
92 | | - |
93 | | - /** |
94 | 24 | * @see MapsBaseMap::setFormInputSettings() |
95 | 25 | * |
96 | 26 | */ |
97 | 27 | protected function setMapSettings() { |
98 | 28 | global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
99 | 29 | |
| 30 | + $this->defaultParams = MapsYahooMapsUtils::getDefaultParams(); |
| 31 | + |
100 | 32 | $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
101 | 33 | $this->defaultZoom = $egMapsYahooMapsZoom; |
102 | 34 | } |
— | — | @@ -107,7 +39,7 @@ |
108 | 40 | protected function doMapServiceLoad() { |
109 | 41 | global $egYahooMapsOnThisPage; |
110 | 42 | |
111 | | - self::addYMapDependencies($this->output); |
| 43 | + MapsYahooMapsUtils::addYMapDependencies($this->output); |
112 | 44 | $egYahooMapsOnThisPage++; |
113 | 45 | |
114 | 46 | $this->elementNr = $egYahooMapsOnThisPage; |
— | — | @@ -120,13 +52,13 @@ |
121 | 53 | public function addSpecificMapHTML() { |
122 | 54 | global $wgJsMimeType; |
123 | 55 | |
124 | | - $this->type = self::getYMapType($this->type); |
125 | | - $this->controls = self::createControlsString($this->controls); |
| 56 | + $this->type = MapsYahooMapsUtils::getYMapType($this->type); |
| 57 | + $this->controls = MapsYahooMapsUtils::createControlsString($this->controls); |
126 | 58 | |
127 | 59 | MapsUtils::makePxValue($this->width); |
128 | 60 | MapsUtils::makePxValue($this->height); |
129 | 61 | |
130 | | - $this->autozoom = self::getAutozoomJSValue($this->autozoom); |
| 62 | + $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom); |
131 | 63 | |
132 | 64 | $markerItems = array(); |
133 | 65 | |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsUtils.php |
— | — | @@ -0,0 +1,95 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/**
|
| 5 | + * A class that holds static helper functions for Yahoo! Maps
|
| 6 | + *
|
| 7 | + * @file Maps_YahooMapsUtils.php
|
| 8 | + * @ingroup Maps
|
| 9 | + *
|
| 10 | + * @author Jeroen De Dauw
|
| 11 | + */
|
| 12 | +
|
| 13 | +if( !defined( 'MEDIAWIKI' ) ) {
|
| 14 | + die( 'Not an entry point.' );
|
| 15 | +}
|
| 16 | +
|
| 17 | +final class MapsYahooMapsUtils {
|
| 18 | +
|
| 19 | + // http://developer.yahoo.com/maps/ajax
|
| 20 | + private static $mapTypes = array(
|
| 21 | + 'normal' => 'YAHOO_MAP_REG',
|
| 22 | + 'YAHOO_MAP_REG' => 'YAHOO_MAP_REG',
|
| 23 | +
|
| 24 | + 'satellite' => 'YAHOO_MAP_SAT',
|
| 25 | + 'YAHOO_MAP_SAT' => 'YAHOO_MAP_SAT',
|
| 26 | +
|
| 27 | + 'hybrid' => 'YAHOO_MAP_HYB',
|
| 28 | + 'YAHOO_MAP_HYB' => 'YAHOO_MAP_HYB'
|
| 29 | + );
|
| 30 | +
|
| 31 | + /**
|
| 32 | + * Returns the Yahoo Map type (defined in MapsYahooMaps::$mapTypes)
|
| 33 | + * for the provided a general map type. When no match is found, the first
|
| 34 | + * Google Map type will be returned as default.
|
| 35 | + *
|
| 36 | + * @param string $type
|
| 37 | + * @return string
|
| 38 | + */
|
| 39 | + public static function getYMapType($type) {
|
| 40 | + global $egMapsYahooMapsType;
|
| 41 | + if (! array_key_exists($type, self::$mapTypes)) $type = $egMapsYahooMapsType;
|
| 42 | + return self::$mapTypes[ $type ];
|
| 43 | + }
|
| 44 | +
|
| 45 | + /**
|
| 46 | + * Build up a csv string with the controls, to be outputted as a JS array
|
| 47 | + *
|
| 48 | + * @param array $controls
|
| 49 | + * @return csv string
|
| 50 | + */
|
| 51 | + public static function createControlsString(array $controls) {
|
| 52 | + global $egMapsYMapControls;
|
| 53 | + return MapsMapper::createJSItemsString($controls, $egMapsYMapControls);
|
| 54 | + }
|
| 55 | +
|
| 56 | + /**
|
| 57 | + * Retuns an array holding the default parameters and their values.
|
| 58 | + *
|
| 59 | + * @return array
|
| 60 | + */
|
| 61 | + public static function getDefaultParams() {
|
| 62 | + return array
|
| 63 | + (
|
| 64 | + 'type' => '',
|
| 65 | + 'autozoom' => '',
|
| 66 | + );
|
| 67 | + }
|
| 68 | +
|
| 69 | + /**
|
| 70 | + * Add references to the Yahoo! Maps API and required JS file to the provided output
|
| 71 | + *
|
| 72 | + * @param string $output
|
| 73 | + */
|
| 74 | + public static function addYMapDependencies(&$output) {
|
| 75 | + global $wgJsMimeType;
|
| 76 | + global $egYahooMapsKey, $egMapsIncludePath, $egYahooMapsOnThisPage;
|
| 77 | +
|
| 78 | + if (empty($egYahooMapsOnThisPage)) {
|
| 79 | + $egYahooMapsOnThisPage = 0;
|
| 80 | + $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script>
|
| 81 | + <script type='$wgJsMimeType' src='$egMapsIncludePath/YahooMaps/YahooMapFunctions.js'></script>";
|
| 82 | + }
|
| 83 | + }
|
| 84 | +
|
| 85 | + /**
|
| 86 | + * Retuns a boolean as string, true if $autozoom is on or yes.
|
| 87 | + *
|
| 88 | + * @param string $autozoom
|
| 89 | + * @return string
|
| 90 | + */
|
| 91 | + public static function getAutozoomJSValue($autozoom) {
|
| 92 | + return MapsMapper::getJSBoolValue(in_array($autozoom, array('on', 'yes')));
|
| 93 | + }
|
| 94 | +
|
| 95 | +
|
| 96 | +} |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -81,6 +81,9 @@ |
82 | 82 | # String. The Google Maps map name prefix. It can not be identical to the one of another mapping service. |
83 | 83 | $egMapsGoogleMapsPrefix = 'map_google'; |
84 | 84 | |
| 85 | +# Array of String. The Google Maps default map types. This value will only be used when the user does not provide one. |
| 86 | +$egMapsGoogleMapsTypes = array('normal', 'satellite', 'hybrid', 'physical'); |
| 87 | + |
85 | 88 | # Integer. The default zoom of a map. This value will only be used when the user does not provide one. |
86 | 89 | $egMapsGoogleMapsZoom = 14; |
87 | 90 | |
— | — | @@ -106,6 +109,9 @@ |
107 | 110 | # String. The Yahoo maps map name prefix. It can not be identical to the one of another mapping service. |
108 | 111 | $egMapsYahooMapsPrefix = 'map_yahoo'; |
109 | 112 | |
| 113 | +# Array of String. The Google Maps default map types. This value will only be used when the user does not provide one. |
| 114 | +$egMapsYahooMapsTypes = array('normal', 'satellite', 'hybrid'); |
| 115 | + |
110 | 116 | # Integer. The default zoom of a map. This value will only be used when the user does not provide one. |
111 | 117 | $egMapsYahooMapsZoom = 4; |
112 | 118 | |
Index: trunk/extensions/Maps/Maps_Utils.php |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * A class that holds static helper functions for Semantic Maps |
| 5 | + * A class that holds static helper functions for common functionality that is map-spesific. |
| 6 | + * Non spesific functions are located in @see MapsParserFunctions |
6 | 7 | * |
7 | 8 | * @file Maps_Utils.php |
8 | 9 | * @ingroup Maps |
— | — | @@ -15,7 +16,7 @@ |
16 | 17 | die ( 'Not an entry point.' ); |
17 | 18 | } |
18 | 19 | |
19 | | -class MapsUtils { |
| 20 | +class MapsUtils { |
20 | 21 | |
21 | 22 | public static function getLatLon($coordinates) { |
22 | 23 | $coordinates = preg_split ( "/,/", $coordinates ); |
Index: trunk/extensions/Maps/Maps_BaseMap.php |
— | — | @@ -14,7 +14,10 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | abstract class MapsBaseMap extends MapsMapFeature { |
18 | | - |
| 18 | + |
| 19 | + // TODO: move this abstract function to a new MApsBaseMapUtils file? |
| 20 | + //protected abstract static function getDefaultParams(); |
| 21 | + |
19 | 22 | protected $markerData = array(); |
20 | 23 | |
21 | 24 | /** |
— | — | @@ -26,8 +29,6 @@ |
27 | 30 | * @return unknown |
28 | 31 | */ |
29 | 32 | public final function displayMap(&$parser, $map) { |
30 | | - $this->defaultParams = $this->getDefaultParams(); |
31 | | - |
32 | 33 | $this->setMapSettings(); |
33 | 34 | |
34 | 35 | $this->doMapServiceLoad(); |
— | — | @@ -84,20 +85,25 @@ |
85 | 86 | private function setCentre() { |
86 | 87 | if (empty($this->centre)) { |
87 | 88 | if (count($this->markerData) == 1) { |
| 89 | + // If centre is not set and there is exactelly one marker, use it's coordinates. |
88 | 90 | $this->centre_lat = $this->markerData[0]['lat']; |
89 | 91 | $this->centre_lon = $this->markerData[0]['lon']; |
90 | 92 | } |
91 | 93 | elseif (count($this->markerData) > 1) { |
92 | | - // TODO |
93 | | - die("// TODO: calculate centre and zoom (with SGM code?)"); |
| 94 | + // If centre is not set and there are multiple markers, set the values to null, |
| 95 | + // to be auto determined by the JS of the mapping API. |
| 96 | + $this->centre_lat = 'null'; |
| 97 | + $this->centre_lon = 'null'; |
94 | 98 | } |
95 | 99 | else { |
| 100 | + // If centre is not set and there are no markers, use the default latitude and longitutde. |
96 | 101 | global $egMapsMapLat, $egMapsMapLon; |
97 | 102 | $this->centre_lat = $egMapsMapLat; |
98 | 103 | $this->centre_lon = $egMapsMapLon; |
99 | 104 | } |
100 | 105 | } |
101 | 106 | else { |
| 107 | + // If a centre value is set, use it. |
102 | 108 | $centre = MapsUtils::getLatLon($this->centre); |
103 | 109 | $this->centre_lat = $centre['lat']; |
104 | 110 | $this->centre_lon = $centre['lon']; |