Talk:Maps
Discussion page moved!
Use the new one on mediawiki.org instead!
Contents
![]() First page |
![]() Previous page |
![]() Next page |
![]() Last page |
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?
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.
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.
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
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 .= '®ion=' . $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 .= '®ion=' . $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();
+ }
+}
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.
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.
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.
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();
+ }
+}
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.
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.
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.
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)
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
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.
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?
The page you linked displays "foo" for "foo", this is the expected behaviour. Are you getting something else?
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..
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 :)
Just wondering if anyone else if having problems when trying to set the default webservice to googlemaps3
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.
The default width is width:100%. This width is problematic width floating objects:
The default width should be width:auto like the CSS default.
Hi!
I want to show the following address in my wiki: 90 Jalan Batu Belig, Kerobokan Kelod, Kuta, Bali, Indonesia
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
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)
This is possible. See here for an example.
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
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 :)
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.
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!!
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?
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.
The issue has been fixed a while back on svn trunk. Working code can be found here.
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?
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.
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?
I'd guess this is some PHP version issue. What version are you using?
Also, can I see the error somewhere online?
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!
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'
);
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
[[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
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
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.
![]() First page |
![]() Previous page |
![]() Next page |
![]() Last page |




