Last modified: 2013-01-18 18:05:24 UTC
When using Semantic Maps to return an #ask query result, it should use the default zoom when there is only one location returned by the query. It does not. I tracked this to SM_MapPrinter.php line 158: if ( $params['zoom'] === false && $locationAmount <= 1 ) { $params['zoom'] = $this->service->getDefaultZoom(); } At first glance the problem seems to be that $locationAmount reports *double* the number of locations that are actually being returned by the query, which prevents the default zoom from being assigned.
What version of Semantic Maps? If you could further debug this and fix the double location stuff, then this might get resolved a lot faster then if you have to wait on me :)
The bug is in the trunk version, but I found it in all versions since 1.0. I did fix it - with: ( $locationAmount / 2 ) <= 1 :). I don't think I'll get the chance to further track it until late next week.
So I finally tracked it to SM_QueryHandler.php line 455 (trunk): $locations[] = $location; The problem is that $locations already has a value. So when $location is added to it, we get 2 locations. Here's a fixed version of the function that seems to work but I'm not confident enough to check it in: protected function buildLocationsList( array $locations, $title, $text, $icon, array $properties ) { if ( $this->template ) { global $wgParser; $parser = version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ? $wgParser : clone $wgParser; } else { $text .= implode( '<br />', $properties ); } $locationsResult = array(); foreach ( $locations as $location ) { if ( $this->template ) { $segments = array_merge( array( $this->template, 'title=' . $title, 'latitude=' . $location->getLatitude(), 'longitude=' . $location->getLongitude() ), $properties ); $text .= $parser->parse( '{{' . implode( '|', $segments ) . '}}', $parser->getTitle(), new ParserOptions() )->getText(); } $location->setTitle( $title ); $location->setText( $text ); $location->setIcon( $icon ); $locationsResult [] = $location; } return $locationsResult; }
Great! Can you submit this to gerrit? https://www.mediawiki.org/wiki/Git/Workflow
In merge queue: https://gerrit.wikimedia.org/r/7730