Index: branches/SemanticMaps0.8/SM_Settings.php |
— | — | @@ -38,6 +38,8 @@ |
39 | 39 | # Commenting or removing a mapping service will cause Semantic Maps to completely ignore it, and so improve performance. |
40 | 40 | # Google Maps API v2 |
41 | 41 | include_once $smgDir . 'includes/services/GoogleMaps/SM_GoogleMaps.php'; |
| 42 | + # Google Maps API v3 |
| 43 | + include_once $smgDir . 'includes/services/GoogleMaps3/SM_GoogleMaps3.php'; |
42 | 44 | # OpenLayers API |
43 | 45 | include_once $smgDir . 'includes/services/OpenLayers/SM_OpenLayers.php'; |
44 | 46 | # Yahoo! Maps API |
Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | $this->service->addParameterInfo( $parameterInfo ); |
70 | 70 | |
71 | 71 | $validator = new Validator( $this->getName(), false ); |
72 | | - $validator->setParameters( $mapProperties, $parameterInfo ); |
| 72 | + $validator->setParameters( $params, $parameterInfo ); |
73 | 73 | $validator->validateParameters(); |
74 | 74 | |
75 | 75 | $fatalError = $validator->hasFatalError(); |
— | — | @@ -95,12 +95,16 @@ |
96 | 96 | public final function getResultText( /* SMWQueryResult */ $res, $outputmode ) { |
97 | 97 | if ( $this->fatalErrorMsg !== false ) { |
98 | 98 | global $wgParser; |
99 | | - $mapName = $this->service->getMapId(); |
100 | 99 | |
101 | | - $queryHandler = SMQueryHandler( $res, $outputmode, $this->parameters ); |
102 | | - $locations = $queryHandler->getLocations(); |
| 100 | + $params = $this->parameters; |
103 | 101 | |
104 | | - return $this->getMapHTML( $this->parameters, $wgParser, $mapName ) . $this->getJSON( $this->parameters, $wgParser, $mapName ); |
| 102 | + $queryHandler = new SMQueryHandler( $res, $outputmode, $params ); |
| 103 | + |
| 104 | + $this->handleMarkerData( $params, $queryHandler->getLocations() ); |
| 105 | + |
| 106 | + $mapName = $this->service->getMapId(); |
| 107 | + |
| 108 | + return $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName ); |
105 | 109 | } |
106 | 110 | else { |
107 | 111 | return $this->fatalErrorMsg; |
— | — | @@ -146,65 +150,33 @@ |
147 | 151 | } |
148 | 152 | |
149 | 153 | /** |
150 | | - * Adds the static locations (specified via the staticlocations parameter) to the map. |
| 154 | + * Converts the data in the coordinates parameter to JSON-ready objects. |
| 155 | + * These get stored in the locations parameter, and the coordinates on gets deleted. |
151 | 156 | * |
152 | | - * TODO |
| 157 | + * @since 0.8 |
153 | 158 | * |
154 | | - * @since 0.7 |
| 159 | + * @param array &$params |
| 160 | + * @param array $queryLocations |
155 | 161 | */ |
156 | | - protected function addStaticLocations() { |
| 162 | + protected function handleMarkerData( array &$params, array $queryLocations ) { |
157 | 163 | global $wgTitle; |
158 | | - |
159 | | - // New parser object to render popup contents with. |
| 164 | + |
160 | 165 | $parser = new Parser(); |
161 | | - |
162 | | - $this->title = $parser->parse( $this->title, $wgTitle, new ParserOptions() )->getText(); |
163 | | - $this->label = $parser->parse( $this->label, $wgTitle, new ParserOptions() )->getText(); |
164 | | - |
165 | | - // Each $location is an array containg the coordinate set as first element, possibly followed by meta data. |
166 | | - foreach ( $this->staticlocations as $location ) { |
167 | | - $markerData = MapsCoordinateParser::parseCoordinates( array_shift( $location ) ); |
168 | | - |
169 | | - if ( !$markerData ) continue; |
170 | | - |
171 | | - $markerData = array( $markerData['lat'], $markerData['lon'] ); |
172 | | - |
173 | | - if ( count( $location ) > 0 ) { |
174 | | - // Parse and add the point specific title if it's present. |
175 | | - $markerData['title'] = $parser->parse( $location[0], $wgTitle, new ParserOptions() )->getText(); |
| 166 | + $iconUrl = MapsMapper::getImageUrl( $params['icon'] ); |
| 167 | + $params['locations'] = array(); |
| 168 | + |
| 169 | + foreach ( array_merge( $params['coordinates'], $queryLocations ) as $location ) { |
| 170 | + if ( $location->isValid() ) { |
| 171 | + $jsonObj = $location->getJSONObject( $params['title'], $params['label'], $iconUrl ); |
176 | 172 | |
177 | | - if ( count( $location ) > 1 ) { |
178 | | - // Parse and add the point specific label if it's present. |
179 | | - $markerData['label'] = $parser->parse( $location[1], $wgTitle, new ParserOptions() )->getText(); |
180 | | - |
181 | | - if ( count( $location ) > 2 ) { |
182 | | - // Add the point specific icon if it's present. |
183 | | - $markerData['icon'] = $location[2]; |
184 | | - } |
185 | | - } |
| 173 | + $jsonObj['title'] = strip_tags( $parser->parse( $jsonObj['title'], $wgTitle, new ParserOptions() )->getText() ); |
| 174 | + $jsonObj['text'] = $parser->parse( $jsonObj['text'], $wgTitle, new ParserOptions() )->getText(); |
| 175 | + |
| 176 | + $params['locations'][] = $jsonObj; |
186 | 177 | } |
187 | | - |
188 | | - // If there is no point specific icon, use the general icon parameter when available. |
189 | | - if ( !array_key_exists( 'icon', $markerData ) ) { |
190 | | - $markerData['icon'] = $this->icon; |
191 | | - } |
192 | | - |
193 | | - if ( $markerData['icon'] != '' ) { |
194 | | - $markerData['icon'] = MapsMapper::getImageUrl( $markerData['icon'] ); |
195 | | - } |
196 | | - |
197 | | - // Temporary fix, will refactor away later |
198 | | - // TODO |
199 | | - $markerData = array_values( $markerData ); |
200 | | - if ( count( $markerData ) < 5 ) { |
201 | | - if ( count( $markerData ) < 4 ) { |
202 | | - $markerData[] = ''; |
203 | | - } |
204 | | - $markerData[] = ''; |
205 | | - } |
206 | | - |
207 | | - $this->locations[] = $markerData; |
208 | | - } |
| 178 | + } |
| 179 | + |
| 180 | + unset( $params['coordinates'] ); |
209 | 181 | } |
210 | 182 | |
211 | 183 | /** |