Talk:Maps

From Mapping on MediaWiki
Jump to: navigation, search
Crystal Clear app error.png

Discussion page moved!
Use the new one on mediawiki.org instead!

Contents

Thread titleRepliesLast modified
Moving a marker in edit mode421:13, June 18, 2011
Geocode suggest ajax service300:29, June 19, 2011
Javascript Service Independent Map Object322:05, June 19, 2011
Custom Markers and Openlayers211:56, May 28, 2011
ParserFunctions not working with Maps enabled511:17, May 6, 2011
Mediawiki 1.17 Requirement119:14, March 24, 2011
Google Maps v3 issues107:55, March 10, 2011
$wgSscriptPath114:28, February 9, 2011
default width215:09, January 31, 2011
Point to address in map117:06, January 21, 2011
alignment of maps on page120:52, January 1, 2011
Maps Pop-Up Resize Issue219:09, December 15, 2010
New error/warning: array_merge() Argument #1 is not an array in...318:22, December 15, 2010
Place for Keys208:41, December 9, 2010
Fatal error: Unsupported operand types in ...1420:29, November 29, 2010
Trimming issue in 0.7 beta 3120:32, November 9, 2010
Undefined method116:03, October 23, 2010
Problem with setting a geocode attribut218:00, October 14, 2010
center issue with sementic maps115:45, October 12, 2010
Geocode nesting115:52, October 12, 2010
First page
First page
Next page
Next page
Last page
Last page

Moving a marker in edit mode

I'd like to allow users to move a location marker on a map that is displayed on a Mediawiki page.

My idea is to have this work in page edit mode... or maybe in a special "edit map" mode.

For example: a user would click on the "edit" tab on the wiki article page. The map would then appear alongside the page text in "edit" mode with some simple instructions shown below the map. The user would be able to zoom into and out of an area on the map, left-click and slide the map around, identify a location, right-click to place a marker, right-click and drag to adjust the position of the marker and finally 'save' which would publish the map on the article page. This functionality is similar to that on http://pathogenomics.bham.ac.uk/hts/

Ideally I would also like to collect the co-ordinates of the marker from the map and publish them automatically on the wiki page to allow indexing.

Then integrate this geodata and other bits of information on the wikipage to make an openlayer for use on openstreetmap and also semantic maps (natch).

Does this sort of functionality appear on your development roadmap?

Payo09:42, June 11, 2011

I think that SemanticMaps provides the functionallity that you are asking for. But it is an extension to Semantic MediaWiki.

I am working on a project where we are hesitating to use Semantic Mediawiki, so I have modified the SemanticMaps and implemented a relationship "haslocation" for vanilla MediaWiki and have a graphical edit view for this integrated with a WYSIWYG editor. The modified SemanticMaps is available here: [1]. It might be a bit specific to our project, but is maybe something that can be built on.

I have also added a couple of things to the Maps extension to be able to save the zoom level and to use ajax suggest for addresses, as I describe in other threads here.

Andreas Jonsson06:14, June 15, 2011
 

This functionality can indeed be obtained by using Maps, Semantic Maps, SMW and Semantic Forms. See here for an example. There is no GUI editing of coordinates further then that. I think it'd be great to have such a feature, but unless someone funds the development for it or the fork of Andreas turns out to be useful, don't expect to see it soon.

Jeroen De Dauw00:57, June 16, 2011
 

How much do you think it would cost?

Payo08:48, June 18, 2011
 

My typical rate for work on Maps is $80/h. The duration depends on what exactly you want, but will definitely be 5h or more. You can contact me by email: jeroendedauw at gmail.com or via Skype: jeroendedauw

Jeroen De Dauw21:13, June 18, 2011
 

Geocode suggest ajax service

I've implemented an ajax service for obtaining a list of autocompletions that can be used for instance with jquery.ui.autocomplete. Here it is as a patch against version 0.7.6. It adds two configuration variables: $egMapsGeocodeDefaultountryBias and $egMapsGeocodeDefaultLanguage. (We are using this in a dialog box in ckeditor for inputing coordinates. The whole thing can be obtained from our project site.) The Yahoo backend is untested.

=== modified file 'extensions/Maps/Maps.hooks.php'
--- extensions/Maps/Maps.hooks.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/Maps.hooks.php	2011-06-07 17:04:19 +0000
@@ -74,5 +74,26 @@
 		
 		return true;
 	}
-	
+
+	public static function getGeocodeSuggestions( $args ) {
+		$argv = split( '\|', $args );
+		$addressFragment = $argv[0];
+		if ( isset($argv[1]) ) {
+			$id = $argv[1];
+		} else {
+			$id = '';
+		}
+
+		$suggestions = MapsGeocoders::getSuggestions( $addressFragment, $id );
+
+		if ( $suggestions != null ) {
+			$response = new AjaxResponse( FormatJson::encode($suggestions->getSuggestions()) );
+			$response->setContentType( 'application/json' );
+		} else {
+			$response = new AjaxResponse( '{ status: "No geocoding service" }' );
+			$response->setContentType( 'application/json' );
+		}
+
+		return $response;
+	}
 } 

=== modified file 'extensions/Maps/Maps.php'
--- extensions/Maps/Maps.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/Maps.php	2011-06-08 12:45:49 +0000
@@ -81,6 +81,9 @@
 $wgAutoloadClasses['iMappingService'] 			= $incDir . 'iMappingService.php';
 $wgAutoloadClasses['MapsMappingServices'] 		= $incDir . 'Maps_MappingServices.php';
 $wgAutoloadClasses['MapsMappingService'] 		= $incDir . 'Maps_MappingService.php';
+$wgAutoloadClasses['MapsGeocodeSuggest']		= $incDir . 'Maps_GeocodeSuggest.php';
+$wgAutoloadClasses['MapsXmlParser'] 			= $incDir . 'Maps_XmlParser.php';
+$wgAutoloadClasses['MapsGeocodeXmlParser']		= $incDir . 'Maps_XmlParser.php';
 
 // Autoload the "includes/criteria/" classes.
 $criDir = $incDir . 'criteria/';
@@ -128,6 +131,9 @@
 $wgAutoloadClasses['MapsGeocode'] 				= $phDir . 'Maps_Geocode.php';
 $wgAutoloadClasses['MapsGeodistance'] 			= $phDir . 'Maps_Geodistance.php';	
 
+// Ajax calls
+$wgAjaxExportList[] = 'MapsHooks::getGeocodeSuggestions';
+
 // To ensure Maps remains compatible with pre 1.16.
 if ( !class_exists( 'Html' ) ) {
 	$wgAutoloadClasses['Html'] = $egMapsDir . 'compat/Html.php';

=== added file 'extensions/Maps/includes/Maps_GeocodeSuggest.php'
--- extensions/Maps/includes/Maps_GeocodeSuggest.php	1970-01-01 00:00:00 +0000
+++ extensions/Maps/includes/Maps_GeocodeSuggest.php	2011-06-07 08:42:13 +0000
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * Class for representing a list of suggested geocodes resulting from
+ * a search.
+ * 
+ * @since
+ * 
+ * @file Maps_GeocodeSuggest.php
+ * @ingroup Maps
+ * 
+ * @author Andreas Jonsson
+ */
+class MapsGeocodeSuggest {
+
+	private $suggestions = array();
+	private $status = null;
+
+	private $curCoordinates = null;
+	private $curLabel = null;
+	private $limit;
+	private $pushes = 0;
+
+	public function __construct( $limit = null ) {
+		$this->limit = $limit;
+	}
+
+	public function push() {
+		if ( $this->curCoordinates != null && $this->curLabel != null
+			&& ($this->limit == null || $this->pushes < $this->limit)
+			&& !isset($this->suggestions[$this->curLabel])
+		) {
+			$this->pushes++;
+			$this->suggestions[$this->curLabel] = $this->curCoordinates;
+		}
+		$this->curCoordinates = null;
+		$this->curLabel = null;
+	}
+
+	public function setLabel( $label ) {
+		$this->curLabel = $label;
+	}
+
+	public function setCoordinates( $coordinates ) {
+		$this->curCoordinates = $coordinates;
+	}
+
+	public function setStatus( $status ) {
+		$this->status = $status;
+	}
+
+	public function getSuggestions() {
+		return array(
+			'suggestions' => $this->suggestions,
+			'status' => $this->status
+		);
+	}
+
+	public function printSuggestions() {
+		foreach( $this->suggestions as $label => $coordinates ) {
+			echo( "{$label}: {$coordinates}\n" );
+		}
+	}
+}

=== modified file 'extensions/Maps/includes/Maps_Geocoder.php'
--- extensions/Maps/includes/Maps_Geocoder.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/Maps_Geocoder.php	2011-06-07 07:01:01 +0000
@@ -159,5 +159,16 @@
 	public function hasGlobalCacheSupport() {
 		return true;
 	}
+
+	/**
+	 * Return a list of suggestions for completing an address
+	 * fragment.
+	 *
+	 * @param string $addressFragment
+	 * @param int $maxSuggestions
+	 * 
+	 * @return MapsGeocodeSuggest
+	 */
+	public abstract function getSuggestions( $addressFragment, $maxSuggestions = 8 );
 	
 }
\ No newline at end of file

=== modified file 'extensions/Maps/includes/Maps_Geocoders.php'
--- extensions/Maps/includes/Maps_Geocoders.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/Maps_Geocoders.php	2011-06-07 08:25:37 +0000
@@ -327,5 +327,20 @@
 		
 		return $geocoderIdentifier;
 	}
-	
+
+	/**
+	 * Get a list of suggested addressess from an address fragment.
+	 *
+	 * @return MapsGeocodeSuggest or null if there is no service that
+	 * is capable of geocoding.
+	 */
+	public static function getSuggestions( $addressFragment, $serviceId ) {
+		if ( self::canGeocode() ) {
+			$geocoder = MapsGeocoders::getValidGeocoderInstance( $serviceId );
+			return $geocoder->getSuggestions( $addressFragment );
+		} else {
+			return null;
+		}
+	}
+
 }

=== added file 'extensions/Maps/includes/Maps_XmlParser.php'
--- extensions/Maps/includes/Maps_XmlParser.php	1970-01-01 00:00:00 +0000
+++ extensions/Maps/includes/Maps_XmlParser.php	2011-06-07 08:43:40 +0000
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Super class for convenient implementation of xml parsers.
+ * 
+ */
+abstract class MapsXmlParser {
+
+	private $parser = null;
+	private $data = array();
+	private $openTags = array();
+	private $closeTags = array();
+
+	public function __construct() {
+		$class = get_class($this);
+		
+		$this->parser = xml_parser_create();
+		xml_set_object( $this->parser, $this );
+
+		foreach ( get_class_methods( $class ) as $m ) {
+			if ( preg_match( '/(.+)_open$/', $m, $matches ) ) {
+				$tag = $matches[1];
+				$this->openTags[$tag] = true;
+			} elseif ( preg_match( '/(.+)_close$/', $m, $matches ) ) {
+				$tag = $matches[1];
+				$this->closeTags[$tag] = true;
+			}
+		}
+
+		xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
+		xml_set_element_handler( $this->parser, 'handleElementOpen', 'handleElementClose' );
+		xml_set_character_data_handler( $this->parser, 'appendData' );
+	}
+
+	function __destruct() {
+		if ( $this->parser != null ) {
+			xml_parser_free( $this->parser );
+		}
+	}
+
+	public function handleElementOpen( $parser, $name, $attribs ) {
+		if ( isset($this->openTags[ $name ]) ) {
+			$this->{"{$name}_open"}($attribs);
+		}
+	}
+
+	public function handleElementClose( $parser, $name ) {
+		if ( isset($this->closeTags[ $name ]) ) {
+			$this->{"{$name}_close"}();
+		}
+	}
+
+	public function appendData( $parser, $data ) {
+		if ( count($this->data) > 0 ) {
+			$this->data[count($this->data) - 1] .= $data;
+		}
+	}
+
+	protected function pushData() {
+		array_push($this->data, '');
+	}
+
+	protected function popData() {
+		return array_pop($this->data);
+	}
+
+	public function parse( $data, $is_final = true ) {
+		xml_parse( $this->parser, $data, $is_final );
+	}
+
+}
+
+/**
+ * Super class for generation of suggestion lists from an XML
+ * response.
+ */
+abstract class MapsGeocodeXmlParser extends MapsXmlParser {
+
+	protected $suggest;
+
+	public function __construct( $limit = null ) {
+		parent::__construct();
+		$this->suggest = new MapsGeocodeSuggest( $limit );
+	}
+
+	public function getSuggestions() {
+		$this->suggest->setStatus( $this->getStatus() );
+		return $this->suggest;
+	}
+
+	protected abstract function getStatus();
+}

=== modified file 'extensions/Maps/includes/geocoders/Maps_GeonamesGeocoder.php'
--- extensions/Maps/includes/geocoders/Maps_GeonamesGeocoder.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/geocoders/Maps_GeonamesGeocoder.php	2011-06-08 12:58:46 +0000
@@ -61,5 +61,77 @@
 			'lon' => $lon
 		);		
 	}
-	
-}
\ No newline at end of file
+
+	public function getSuggestions( $addressFragment, $maxSuggestions = 5 ) {
+		global $egMapsGeocodeDefaultCountryBias, $egMapsGeocodeDefaultLanguage;
+
+		$url =	'http://ws.geonames.org/search?q='
+			. urlencode( $addressFragment )
+			. '&maxRows=' . $maxSuggestions;
+
+		if ( isset($egMapsGeocodeCountryBias) ) {
+			$url .= '&countryBias=' . $egMapsGeocodeDefaultCountryBias;
+		}
+
+		if ( isset($egMapsGeocodeLanguage) ) {
+			$url .= '&language=' . $egMapsGeocodeDefaultLanguage;
+		}
+
+		wfDebug('Requesting from geoservice: "' . $url . "\n");
+		$response = Http::get( $url );
+
+		wfDebug('Got response: "' . $response . "\"\n" );
+		$parser = new MapsGeonamesGeocodeXmlParser();
+		$parser->parse( $response );
+
+		return $parser->getSuggestions();
+	}
+	
+}
+
+class MapsGeonamesGeocodeXmlParser extends MapsGeocodeXmlParser {
+
+	private $status = null;
+	private $location = null;
+
+	public function geoname_open() {
+		$this->location = array(null, null);
+	}
+
+	public function geoname_close() {
+		$l = $this->location;
+		if ( $l[0] != null && $l[1] != null ) {
+			$this->suggest->setCoordinates( "{$l[0]},{$l[1]}" );
+		}
+		$this->location = null;
+		$this->suggest->push();
+	}
+	
+	public function lat_open() {
+		$this->pushData();
+	}
+
+	public function lat_close() {
+		$this->location[0] = $this->popData();
+	}
+
+	public function lng_open() {
+		$this->pushData();
+	}
+
+	public function lng_close() {
+		$this->location[1] = $this->popData();
+	}
+
+	public function toponymName_open() {
+		$this->pushData();
+	}
+
+	public function toponymName_close() {
+		$this->suggest->setLabel( $this->popData() );
+	}
+
+	public function getStatus() {
+		return 'OK';
+	}
+}

=== modified file 'extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php'
--- extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php	2011-06-07 20:49:09 +0000
@@ -77,5 +77,91 @@
 	public static function getOverrides() {
 		return array( 'googlemaps2', 'googlemaps3' );
 	}
-	
-}
\ No newline at end of file
+
+	public function getSuggestions( $addressFragment, $maxSuggestions = 8 )	 {
+		global $egMapsGeocodeDefaultCountryBias;
+		global $egMapsGeocodeDefaultLanguage;
+		$url =	'http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address='
+			. urlencode( $addressFragment );
+
+		if ( isset($egMapsGeocodeDefaultCountryBias) ) {
+			$url .= '&region=' . $egMapsGeocodeDefaultCountryBias;
+		}
+
+		if ( isset($egMapsGeocodeDefaultLanguage) ) {
+			$url .= '&language=' . $egMapsGeocodeDefaultLanguage;
+		}
+		
+		$response = Http::get( $url );
+
+		$parser = new MapsGoogleGeocodeXmlParser( $maxSuggestions );
+		$parser->parse( $response );
+
+		return $parser->getSuggestions();
+	}
+}
+
+class MapsGoogleGeocodeXmlParser extends MapsGeocodeXmlParser {
+
+	private $status = null;
+	private $location = null;
+
+	public function __construct( $limit ) {
+		parent::__construct( $limit );
+	}
+
+	public function status_open() {
+		$this->pushData();
+	}
+
+	public function status_close() {
+		$this->status = $this->popData();
+	}
+
+	public function getStatus() {
+		return $this->status;
+	}
+
+	public function result_open() {
+	}
+
+	public function result_close() {
+		$this->suggest->push();
+	}
+
+	public function formatted_address_open() {
+		$this->pushData();
+	}
+
+	public function formatted_address_close() {
+		$this->suggest->setLabel( $this->popData() );
+	}
+
+	public function location_open() {
+		$this->location = array(null, null);
+	}
+
+	public function location_close() {
+		$l = $this->location;
+		if ( $l[0] != null && $l[1] != null ) {
+			$this->suggest->setCoordinates( "{$l[0]},{$l[1]}" );
+		}
+		$this->location = null;
+	}
+
+	public function lat_open() {
+		$this->pushData();
+	}
+
+	public function lat_close() {
+		$this->location[0] = $this->popData();
+	}
+
+	public function lng_open() {
+		$this->pushData();
+	}
+
+	public function lng_close() {
+		$this->location[1] = $this->popData();
+	}
+}

=== modified file 'extensions/Maps/includes/geocoders/Maps_YahooGeocoder.php'
--- extensions/Maps/includes/geocoders/Maps_YahooGeocoder.php	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/geocoders/Maps_YahooGeocoder.php	2011-06-07 08:44:25 +0000
@@ -72,5 +72,132 @@
 	public static function getOverrides() {
 		return array( 'yahoomaps' );
 	}
-	
-}
\ No newline at end of file
+
+	public function getSuggestions( $addressFragment, $maxSuggestions = 8 )	 {
+		global $egGoogleMapsKey;
+		global $egMapsGeocodeDefaultCountryBias;
+		global $egMapsGeocodeDefaultLanguage;
+		$url =	'http://maps.google.com/maps/geo?q='
+			. urlencode( $addressFragment )
+			. '&key=' . urlencode( $egGoogleMapsKey )
+			. '&output=xml';
+
+		if ( isset($egMapsGeocodeCountryBias) ) {
+			$url .= '&region=' . $egMapsGeocodeDefaultCountryBias;
+		}
+
+		if ( isset($egMapsGeocodeLanguage) ) {
+			$url .= '&language=' . $egMapsGeocodeDefaultLanguage;
+		}
+		
+		$response = Http::get( $url );
+
+		$parser = new MapsYahooGeocodeXmlParser( $maxSuggestions );
+		$parser->parse( $response );
+
+		return $parser->getSuggestions();
+	}
+}
+
+class MapsYahooGeocodeXmlParser extends MapsGeocodeXmlParser {
+
+	private $error = null;
+	private $errorMessage = null;
+	private $location = null;
+	private $line;
+
+	public function Error_open() {
+		$this->pushData();
+	}
+
+	public function Error_close() {
+		$this->error = $this->popData();
+	}
+
+	public function ErrorMessage_open() {
+		$this->pushData();
+	}
+
+	public function ErrorMessage_close() {
+		$this->errorMessage = $this->popData();
+	}
+
+	public function getStatus() {
+		if ( isset($this->error) && $this->error == 0 ) {
+			return 'OK';
+		} else {
+			return $this->errorMessage;
+		}
+	}
+
+	public function Result_open() {
+		$this->line = array(null, null, null);
+		$this->location = array(null, null);
+	}
+
+	public function Result_close() {
+		$l = $this->location;
+		if ( $l[0] != null && $l[1] != null ) {
+			$this->suggest->setCoordinates( "{$l[0]},{$l[1]}" );
+		}
+		if ( $this->line1 != null ) {
+			$label = $this->line1;
+			$first = false;
+		}
+		$label = '';
+		$first = true;
+		foreach ( array( 0, 1, 2 ) as $i ) {
+			if ( $this->line[$i] != null ) {
+				if ($first) {
+					$first = false;
+				} else {
+					$label .= ' ';
+				}
+				$label .= $this->line[$i];
+			}
+		}
+		$this->suggest->setLabel( $label );
+		$this->location = null;
+		$this->suggest->push();
+	}
+
+	public function line1_open() {
+		$this->pushData();
+	}
+
+	public function line1_close() {
+		$this->line[0] = $this->popData();
+	}
+
+	public function line2_open() {
+		$this->pushData();
+	}
+
+	public function line2_close() {
+		$this->line[1] = $this->popData();
+	}
+
+	public function line3_open() {
+		$this->pushData();
+	}
+
+	public function line3_close() {
+		$this->line[2] = $this->popData();
+	}
+
+	public function latitude_open() {
+		$this->pushData();
+	}
+
+	public function latitude_close() {
+		$this->location[0] = $this->popData();
+	}
+
+	public function longitude_open() {
+		$this->pushData();
+	}
+
+	public function longitude_close() {
+		$this->location[1] = $this->popData();
+	}
+}

Andreas Jonsson13:07, June 8, 2011

Neat! Can I see this in action somewhere? Also, where can I download your patched version (Can't find any way to get a tarball or checkout the source on the site you linked)? If it works nicely I'll probably do the effort of merging it into trunk (which has changed quite a bit since 0.7.6).

I did see you made quite some changes and also created some MapsForms extension. What's your motivation behind this work? If you want your additions to be available for everyone in the main version of the extensions, you're probably better of getting commit access to the WMF SVN repo, so you don't end up with a version that diverges so much from the main one that it's a pain to merge things, if possible at all. I can provide more info on the process if needed :)

Edit: just had another quick look at your code. If you fork something and do not rewrite virtually everything, it's considered not very nice to remove the original authors and claim it as your own.

Jeroen De Dauw00:51, June 16, 2011
 

I apologize about the missing credits! I started to work on it as a separate extension and copied the code from Semantic Maps later and forgot to update the meta data. I will fix it!

You could check out our demowiki. Create a user (and change language to english under "Mina inställningar", unless you speak swedish). Go to some page other than the front page, for instance, this one and edit it. You'll get a graphical edit view. Click on the icon of a treasure map and you'll get the "place on map" dialog window.

Andreas Jonsson23:43, June 18, 2011
 

Regarding MapsForms, we're using it as a method to input coordinates from a dialog window. I wanted an abstraction layer and saw that Semantic Maps provided mostly what I needed. I have rather crudely removed SMW specific code from Semantic Forms and tailored it to fit our use case, and haven't had any ambitions to make it more widely usable.

Andreas Jonsson00:29, June 19, 2011
 

Javascript Service Independent Map Object

I am using the Maps extension and my specific problem is that I want to acquire the current zoom level using a javascript. But there is no service independent way to interact with the map object from a javascript. I thought it might be a good idea to introduce a javascript wrapper object for the map objects that provides a service independent interface.

With the below patch it should be possible to obtain a reference to this wrapper object for instance using jquery:

 var map = $('#mapName').find('.mapReference').get( 0 ).mw_maps_map

What do you think about this? Here is a patch against version 0.7.6 that adds the start of such a wrapper object:

=== modified file 'extensions/Maps/includes/services/GoogleMaps/GoogleMapFunctions.js'
--- extensions/Maps/includes/services/GoogleMaps/GoogleMapFunctions.js	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/services/GoogleMaps/GoogleMapFunctions.js	2011-06-01 07:18:46 +0000
@@ -305,6 +305,12 @@
 	}
 	window.GMaps[mapName] = map;
 
+ 	var mapReference = document.createElement( 'div' );
+	mapReference.setAttribute( 'style', 'display:none' );
+	mapReference.setAttribute( 'class', 'mapReference' );
+	mapReference.mw_maps_map = new Maps_GoogleMapsMapWrapper( map );
+	mapElement.appendChild( mapReference );
+
 	return map;
 }
 
@@ -397,4 +403,12 @@
 function initiateGOverlay(elementId, mapName, urlNr) {
 	document.getElementById(elementId).checked = true;
 	switchGLayer(GMaps[mapName], true, GOverlays[urlNr]);
-}
\ No newline at end of file
+}
+
+function Maps_GoogleMapsMapWrapper( map ) {
+	this.map = map;
+
+	this.getZoom = function() {
+		return this.map.getZoom();
+	}
+}

=== modified file 'extensions/Maps/includes/services/GoogleMaps3/GoogleMap3Functions.js'
--- extensions/Maps/includes/services/GoogleMaps3/GoogleMap3Functions.js	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/services/GoogleMaps3/GoogleMap3Functions.js	2011-06-01 08:06:54 +0000
@@ -15,6 +15,12 @@
 	
 	var map = new google.maps.Map( document.getElementById( name ), options );
 	
+ 	var mapReference = document.createElement( 'div' );
+	mapReference.setAttribute( 'style', 'display:none' );
+	mapReference.setAttribute( 'class', 'mapReference' );
+	mapReference.mw_maps_map = new Maps_GoogleMaps3MapWrapper( map );
+	mapElement.appendChild( mapReference );
+
 	// TODO: types - http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeRegistry
 	
 	for ( var i = markerData.length - 1; i >= 0; i-- ) {
@@ -41,4 +47,12 @@
 	} );
 	
 	return marker;
-}
\ No newline at end of file
+}
+
+function Maps_GoogleMaps3MapWrapper( map ) {
+	this.map = map;
+
+	this.getZoom = function() {
+		return this.map.getZoom();
+	}
+}

=== modified file 'extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js'
--- extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/services/OpenLayers/OpenLayerFunctions.js	2011-06-01 06:55:10 +0000
@@ -109,6 +109,12 @@
 	}
 	
 	if (zoom != null) map.zoomTo(zoom); // When the zoom is provided, set it.
+
+ 	var mapReference = document.createElement( 'div' );
+	mapReference.setAttribute( 'style', 'display:none' );
+	mapReference.setAttribute( 'class', 'mapReference' );
+	mapReference.mw_maps_map = new Maps_OpenLayersMapWrapper( map );
+	mapElement.appendChild( mapReference );
 	
 	return map;
 }
@@ -184,4 +190,12 @@
 			'minSize': new OpenLayers.Size(minWidth, minHeight)
 		}
 	);
+}
+
+function Maps_OpenLayersMapWrapper( map ) {
+	this.map = map;
+
+	this.getZoom = function() {
+		return this.map.getZoom();
+	}
 }
\ No newline at end of file

=== modified file 'extensions/Maps/includes/services/YahooMaps/YahooMapFunctions.js'
--- extensions/Maps/includes/services/YahooMaps/YahooMapFunctions.js	2011-05-06 15:42:28 +0000
+++ extensions/Maps/includes/services/YahooMaps/YahooMapFunctions.js	2011-06-01 08:01:25 +0000
@@ -58,6 +58,12 @@
 	if (! typesContainType) types.push(type);	 
 	 
 	var map = new YMap(mapElement, type); 
+
+ 	var mapReference = document.createElement( 'div' );
+	mapReference.setAttribute( 'style', 'display:none' );
+	mapReference.setAttribute( 'class', 'mapReference' );
+	mapReference.mw_maps_map = new Maps_YahooMapsMapWrapper( map );
+	mapElement.appendChild( mapReference );
 	
 	map.removeZoomScale();
 	
@@ -110,4 +116,12 @@
 	if ( centre != null ) map.drawZoomAndCenter( centre );
 	
 	return map;
-}
\ No newline at end of file
+}
+
+function Maps_YahooMapsMapWrapper( map ) {
+	this.map = map;
+
+	this.getZoom = function() {
+		return this.map.getZoomLevel();
+	}
+}
Andreas Jonsson08:29, June 1, 2011

What exactly do you need this for? The approach you propose doesn't seem very nice, but then again, the JS of Maps < 1.0 is rather crappy. It's been completely rewritten to a bunch of jQuery plugins in the current dev version. It's probably possible to add some event to those that gets triggered when the zoom level changes or maybe simply a method that obtains the current zoomlevel. I'm not convinced this is very useful though.

Jeroen De Dauw00:39, June 16, 2011
 

The general problem is to access the properties and methods of a map from an external javascript, simply by accessing the map via its id, without having to care about which service is used to generate it. In my use case, we are integrating the map in a dialog window of ckeditor, so we sometimes want such access. Another application might be to remove the marker from the map, which we currently implement by requesting a new map from the server.

Andreas Jonsson00:03, June 19, 2011
 

I see. Such information can be kept in the jQuery map objects in version 1.0 and later. At the moment they are all completely independent from eachother, but it should be relatively easy to create a base jQuery map object that each mapping service extends, so you end up having a single interface to the data and interaction with the maps. This will also simply the map form inputs in Semantic Maps, esp if new, more complex, functionality is added to them. I might have a further look at this after version 1.0(.x) has stabilized. You are of course welcome to help out if you want. If this is the case, I can set up a branch on which this can be done, so there is no need to wait for the 1.0 release cycle to be completed.

Jeroen De Dauw22:05, June 19, 2011
 

Custom Markers and Openlayers

Using Maps 0.7.6.1 on MW 1.16.5 .

When openlayers is defined any custom markers specified appear squashed vertically.

Is there a workaround for this? Am I doing something wrong?

Note: this is not the same problem as when not using openlayers and where icons can appear a little squashed and a browser refresh appears to fix the display of markers.

Thanks for any help.

--Skyhook 02:24, May 27, 2011 (EDT)

Skyhook06:24, May 27, 2011

This is a limitation of Maps 0.7.6.1, with no easy work around. I'll see if it can be fixed for the upcoming 1.0 release, and possibly backport the fix for 0.7.x :)

Jeroen De Dauw16:03, May 27, 2011
 

Thank you for your help!  :)

Skyhook11:56, May 28, 2011
 

ParserFunctions not working with Maps enabled

Maps 0.7.5.1 on MW1.16 causes ParserFunctions (1.3) not to work. I disabled it for now, but here's my current installation: http://oogstenzonderzaaien.nl/wiki/Speciaal:Softwareversie

82.156.5.1308:42, April 23, 2011

In what way does it not work? I just checked on my MW 1.16 install with Maps 0.7.6.1 and the latest version of ParserFunctions, and it all appeared to work as expected.

Jeroen De Dauw14:25, April 25, 2011
 

even the simplest test did not work, just showed the syntax as text. I had 0.7.5.1 installed though, not 0.7.6.1 could that make any difference?

82.156.5.1317:32, April 27, 2011
 

The page you linked displays "foo" for "foo", this is the expected behaviour. Are you getting something else?

Jeroen De Dauw12:48, May 3, 2011
 

Damn, I meant "foo" for "{{#if:foo|foo|bar}}".

Jeroen De Dauw12:49, May 3, 2011
 

I solved the problem, figured out I hadn't installed the Validator. Now it works as expected!

82.156.5.1311:17, May 6, 2011
 

Mediawiki 1.17 Requirement

You need to update the requirements on the homepage for the latest version. 1.17 is still in alpha stage, and few production systems will actually be running it. Your latest download will not work on anything older than 1.17, which is probably a good majority of installed mediawiki installations. That or offer a download that will work with older systems. Thanks!

Oh, and your captcha is broken for anon posters..

Kingu15:38, March 23, 2011

The latest release (0.7.6.1) does work with 1.15.x and 1.16.x. When making the release, I accidentally created archives with version 0.8 alpha, which is not compatible with pre 1.17, and probably gave you an error message, resulting in your post here. Sorry for the confusion, the archive has been re-uploaded with the correct versions :)

Jeroen De Dauw19:14, March 24, 2011
 

Google Maps v3 issues

Just wondering if anyone else if having problems when trying to set the default webservice to googlemaps3

142.103.101.7723:35, March 9, 2011

$wgSscriptPath

It seems that you need to put the require_once command in LocalSettings AFTER setting $wgScriptPath (Mediawiki 1.15) due to setting of $egMapsScriptPath in Maps.php.

Ianb146914:28, February 3, 2011

Yeah; in general, you should put extensions at the bottom of your LocalSettings file. If some documentation states otherwise, please correct it or point me to where it is.

Jeroen De Dauw14:28, February 9, 2011
 

default width

Box

The default width is width:100%. This width is problematic width floating objects:

div container with width:100%


Box

The default width should be width:auto like the CSS default.

div container with width:auto
141.113.85.9516:14, January 26, 2011

Awesome; thanks for pointing this out. I'll fix this for the next release.

Jeroen De Dauw21:01, January 26, 2011

It's fixed on trunk now.

Jeroen De Dauw15:09, January 31, 2011
 
 

Point to address in map

Hi!

I want to show the following address in my wiki: 90 Jalan Batu Belig, Kerobokan Kelod, Kuta, Bali, Indonesia

This address exist - see here: http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=90+Jalan+Batu+Belig,+Kerobokan+Kelod,+Kuta,+Bali,+Indonesia&aq=0&sll=37.0625,-95.677068&sspn=31.509065,86.044922&ie=UTF8&hq=&hnear=Jalan+Batu+Belig,+Kerobokan+Kelod,+Kuta,+Badung,+Bali,+Indonesia&ll=-8.671906,115.15367&spn=0.019091,0.041757&z=15

But my wiki map doesn't want to accept this address! What am I doing wrong?

Feel free try your luck: http://www.auslandssemester-bali.de/index.php?title=Map-Test



Thanks for your help! Chris

220.255.2.2511:21, January 21, 2011

Apparently the Google Geocoding service is not able to convert your address to a set of coordinates. I suggest you try to rephrase it to something it does recognize, or simply use an online geocoding service to convert the address to a set of coordinates, and use these directly.

Jeroen De Dauw17:06, January 21, 2011
 

alignment of maps on page

Hi there,

I would like to put a map next to a infobox in my mediawiki (on the right hand side). Can anyone tell me how to do that? Please have a look here: http://www.auslandssemester-bali.de/index.php?title=Map-Test

It would be perfect if I could use a floating map with hight of 600px. I couldn't figure out yet how to do that.


(I'm using maps 0.7.3)

202.156.14.10612:40, January 1, 2011

This is possible. See here for an example.

Jeroen De Dauw20:52, January 1, 2011
 

Maps Pop-Up Resize Issue

Hello again J,

My pop-up boxes, which contain a list of properties and their values, are not resizing correctly. If less than 8 lines of text are present, the text will extend beyond the bottom of the box. If 9+ lines are present, the box will resize correctly. I am not using a template. The issue has been viewed on both IE and Opera browsers. Is there a fix for this?

I'm running: MW 1.15.1 ; SMW 1.5.1.1 ; Maps/Semantic Maps 0.6.5 ; Validator 0.3.5

Darryl

149.32.192.3419:28, December 8, 2010

Someone else reported this and I fixed it at some point, which IIRC, was after 0.6.5. So upgrading to the latest release should fix the issue. Let me know if it does not :)

Jeroen De Dauw06:03, December 9, 2010

I upgraded to 0.7.3 and the problem is still present, although it did add a scroll bar.

My problem is identical to this one.

149.32.192.3419:09, December 15, 2010
 
 

New error/warning: array_merge() Argument #1 is not an array in...

This error just popped up on my site. I haven't made any changes to my mediawiki setup in about a month (haven't added any new extensions either).

Looks like this: Warning: array_merge() function.array-merge] Argument #1 is not an array in /home/abc/xyz/extensions/Maps/Maps.php on line 180

Any ideas? Thanks in advance!!

Kburns16:58, December 14, 2010

As it turns out line 180 is where I had edited Maps.php as per my previous question about the "Fatal error: Unsupported operand types in..."

You can see there here: http://mapping.referata.com/wiki/Thread:Talk:Maps/Fatal_error:_Unsupported_operand_types_in_/home/me/public_html/extensions/Maps/Maps.php_on_line_174

Line 180 is the final line here:


      $wgExtraNamespaces = array_merge( $wgExtraNamespaces, array(
              	Maps_NS_LAYER => 'Layer',
              	Maps_NS_LAYER_TALK => 'Layer talk'
      ) );

Does this help any?

Kburns05:00, December 15, 2010

Some more updates...

I realized that someone brought this problem up below, but I had not seen it after implementing the little code hack. I upgraded from 0.7.2 to 0.7.3 and still see it appearing.

Kburns05:14, December 15, 2010

The issue has been fixed a while back on svn trunk. Working code can be found here.

Jeroen De Dauw18:22, December 15, 2010
 
 
 

Place for Keys

Installed Maps as described and set Google and yahoo Key in LocalSettings.php. No Effect.

Then i found the /extension/Maps/Maps_Settings.php. Am I wrong or is this the only Place to place the google and yahoo keys?

Agaida19:57, December 8, 2010

You should not modify any code in the extensions/Maps folder, as it'll get lost next time you update the code. LocalSettings is the correct place. Note that you have to place the setting (such as $egMapsGoogleMapsKey ='something';) AFTER the inclusion of the extension. If you place it before, it'll get overridden by what's in Maps_Settings.php.

Jeroen De Dauw06:05, December 9, 2010

Thanks. LocalSettings is the right place. But you have to paste the right key too - my fault. ;)

Agaida08:41, December 9, 2010
 
 

Fatal error: Unsupported operand types in ...

Hi there -

I am a bit new to MediaWiki, but I have successfully installed a bunch of extensions. My LocalSettings.php has the proper include for Maps.php followed by my google and yahoo api keys.

The error I see is: Fatal error: Unsupported operand types in /home/me/public_html/extensions/Maps/Maps.php on line 174

I am running MediaWiki v1.15.1 and trying to install Maps v0.7.2 (w Validator v0.4.2 that came bundled). As far as I can tell these versions should work together.

Any ideas?

Kburns05:22, November 7, 2010

I'd guess this is some PHP version issue. What version are you using?

Also, can I see the error somewhere online?

Jeroen De Dauw20:18, November 7, 2010

Yea, I am using:

PHP: 5.2.9 (cgi) MySQL: 5.0.91mm-log

I can't show this online because I need to have the site running, but the error message I posted is all that appears when the page loads.

Thanks for your help!

Kburns03:51, November 9, 2010

Not sure if this helps (you probably already knew this), but line 174 is the final line here:


       $wgExtraNamespaces += array(
              	Maps_NS_LAYER => 'Layer',
              	Maps_NS_LAYER_TALK => 'Layer talk'
       );
Kburns04:18, November 9, 2010

That's odd... PHP 5.2.9 should support += for arrays. Anyway, this code is synonymous, so will probably get rid of the issue for you:

       $wgExtraNamespaces = array_merge( $wgExtraNamespaces, array(
              	Maps_NS_LAYER => 'Layer',
              	Maps_NS_LAYER_TALK => 'Layer talk'
       ) );
Jeroen - LQT is failing when I login05:26, November 9, 2010
 
 
 
 

Trimming issue in 0.7 beta 3

In reply to this discussion:

This should be fixed now, and will be in RC1.

Jeroen De Dauw16:00, October 10, 2010

Cool, great to hear.

Yaron Koren20:32, November 9, 2010
 

Undefined method

After installing Maps version 0.7.1.7, I get these errors:

  • Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in /var/www/vhosts/kgv.nl/httpdocs/wiki/includes/EditPage.php on line 1086
  • Fatal error: Call to undefined method Title::isSpecialPage() in /var/www/vhosts/kgv.nl/httpdocs/wiki/extensions/Maps/includes/features/Maps_BaseMap.php on line 98

Has anyone got an idea how to deal with them?

Ruud

83.160.112.22014:12, October 21, 2010

Maps 0.7.1 does not work with MW 1.15.x or lower (this is a bug). Maps 0.7 does work correctly with these older versions of MediaWiki, and so will Maps 0.7.2.

I recommend you upgrade your MW if possible, and otherwise install Maps 0.7 instead of 0.7.1.

Jeroen De Dauw16:03, October 23, 2010
 

Problem with setting a geocode attribut

The code
[[Coordinates:: {{#geocode:Mehringstraße, Gelsenkirchen, Germany|format=float|directional=no|service=google}}]]
does not work to set a geocode attribut. I guess it's up to a newline, which is printed before the coordinates. You can see the behavior on this test site: http://stadtwiki.ge1.de/index.php/Test

I'm using semantic maps 0.7 RC1

87.123.62.20207:38, October 14, 2010

It's fixed, and will be in 0.7, which will be released tomorrow :)

Jeroen De Dauw14:21, October 14, 2010

thanks for the quick turnaround and many thanks for this excellent extension.

87.123.41.7818:00, October 14, 2010
 
 

center issue with sementic maps

I found the center parameter doesn't work with #ask query:

Fatal error: Call to undefined method MapsGeocoder::attemptToGeocode() in 
/home/xxxxx/transitunlimited.org/extensions/SemanticMaps/includes/queryprinters/SM_MapPrinter.php on line 465
67.170.217.24719:03, October 11, 2010

Great find - it's fixed now on SVN trunk and will be in 0.7.

Jeroen De Dauw15:45, October 12, 2010
 

Geocode nesting

The old version allows nesting, but not the new version:

{{#compound_query:[[latlong::{{#geocode:1250 San Carlos Avenue, San Carlos, CA|google}} ({{{distance|1}}} mile)]][[Category:Rail stations]];?latlong;icon=Rail20.png
    |[[latlong::{{#geocode:1250 San Carlos Avenue, San Carlos, CA|google}}  ({{{distance|1}}} mile)]];?latlong;?Served by=Line;?-rail=Bus;?-Place=Bus
    |format=googlemaps2|controls=small,type,scale,searchbar|width={{{width|600}}}|height={{{height|500}}}|centre={{#geocode:1250 San Carlos Avenue, San Carlos, CA|google}}}}

If I use the geocode tag alone, it works:

{{#geocode:1250 San Carlos Avenue, San Carlos, CA|google}}

Also if I use the Semantic Search page, this is what I got (you can also find it here) when I try to display the results as a page:

Fatal error: Call to undefined method MapsGoogleMaps::getTypeNames() in 
/home/xxxxx/transitunlimited.org/extensions/SemanticMaps/includes/services/GoogleMaps/SM_GoogleMapsQP.php on line 71

The new version is stable enough for the site so I am keeping it for now. I am not using the geocode feature for now any way.

67.170.217.24718:30, October 11, 2010

The nesting issue is tricky - I don't see any immediate way to fix it. Note that the centre parameter does support smart geocoding, so it's not needed to nest a #geocode call there.

The fatal error has been fixed on SVN trunk and will be gone in 0.7.

Jeroen De Dauw15:52, October 12, 2010
 
First page
First page
Next page
Next page
Last page
Last page
Personal tools
Namespaces
Variants
Views
Actions
Navigation
Manuals
Useful lists
More awesomeness
Toolbox