Extension talk:Maps

Jump to navigation Jump to search

About this board

Post questions, bug reports and feature requests at https://github.com/JeroenDeDauw/Maps/issues.

The maintainer of the Maps extension does not check this page frequently!

The documentation for the Maps extension is located at https://www.semantic-mediawiki.org/wiki/Extension:Maps


imageoverlays - no equivalent for leaflet?

NeirinD (talkcontribs)


maybe I am just configuring the parameters the wrong way. I would like to overlay some parts of the map with images of my own, so I can use the geocoding to show where things are, but have them shown on the image instead of the normal map-base.

The imageoverlays parameter (googlemaps3) seems like it would to the trick, but I just can't get the overlays to work in Leaflet (OSM). From the LeafletService.php/DefaultSettings.php it seems like one can only use predetermined overlays for the maps.

Is there a workaround or am I stuck with Gmaps? Thanks

Reply to "imageoverlays - no equivalent for leaflet?"
Cible30 (talkcontribs)

Hello, i'm trying to do a interactive query with page form that display a map with only the subject selected by the visitor. I've written all the codes but in the runquery page the map doesn't load. The code:

  • Template Mappa interattiva:

 [[Category:Campione generico]]
 ; {{#if: {{{specie|}}} | [[Specie::{{{specie|}}}]] |   }}
 ; {{#if: {{{genere|}}} | [[Genere::{{{genere|}}}]] |   }}
 ; {{#if: {{{sottofamiglia|}}} | [[Sottofamiglia::{{{sottofamiglia|}}}]] |   }}
 ; {{#if: {{{famiglia|}}} | [[Famiglia::{{{famiglia|}}}]] |   }}
 ; ?Coordinate
 ; icon=Campione generico.png
 | format=leaflet
 | fullscreen=yes
 | cluster=yes
 | clusterspiderfy=yes
 | clusterzoomonclick=yes
 | zoom=5
 | layers=OpenTopoMap,OpenStreetMap

  • Form:

{{{standard input|run query|label=Cerca}}}
{{{info|query form at top}}}
{{{for template|Mappa interattiva}}}

{| class="formtable"
! Specie:
| {{{field|specie|input type=combobox|existing values only}}}
! Genere:
| {{{field|genere|input type=combobox|existing values only}}}
! Sottofamiglia:
| {{{field|sottofamiglia|input type=combobox|existing values only}}}
! Famiglia:
| {{{field|famiglia|input type=combobox|existing values only}}}
{{{end template}}}

Are there some errors or is not possible to display maps in the special page runquery?

Tgschaef (talkcontribs)

Chiming in to say I have the same problems. You are not alone. Even a plain #ask format=leaflet or googlemap, that works on normal pages will not work on a Run Query template.

Reply to "Map don't load on form"

Add Maps icon to WikiEditor toolbar

Felix Englisch (talkcontribs)

If you are using the Maps extension in combination with Extension:WikiEditor, you might want to make it easier for your users to insert a map. It is quite easy to add an icon to the toolbar which automatically inserts the code snippet required for embedding. Simply add the following to you LocalSettings.php:

$wgUseSiteJs = true;

Then, open the page "MediaWiki:Common.js" on your wiki and insert the following:

var customizeToolbar = function () {
  $('#wpTextbox1').wikiEditor('addToToolbar', {
      section: 'advanced',
      group: 'insert',
      tools: {
        "Map": {
          label: 'Insert map',
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/b/b4/OOjs_UI_icon_map-ltr.svg',
          action: {
            type: 'encapsulate',
            options: {
              pre: '{{#display_map:',
              peri: "Example street 1, Berlin~'''Heading'''~Short description; optional: 2nd marker",
              post: '|fullscreen=on}}'
    /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
    if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
    mw.loader.using( 'user.options' ).then( function () {
    if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
        mw.loader.using( 'ext.wikiEditor' ), $.ready
      ).then( customizeToolbar );
  } );

Of course, you can change the default parameters of the map and also the icon. Just visit https://commons.wikimedia.org/wiki/Main_Page and look for a better one. And for more information about editing the toolbar, see Extension:WikiEditor/Toolbar customization.

Have fun!

Reply to "Add Maps icon to WikiEditor toolbar"

Extract country from address or coordinates

Planetenxin (talkcontribs)

Is there a way to extract the country from a given address or coordinates?

Jeroen De Dauw (talkcontribs)

No. Maps does not currently support reverse geocoding. Contributions are welcome though, including in the form of funding.

Reply to "Extract country from address or coordinates"

Can't seem to get Pages to show on Map

2 (talkcontribs)

What I want: A map showing all pages in a category that have a Location field filled out with a city and state in the template

What I tried:

  • Creating the Location Property and adding it to the template used on all the pages in that category
  • Creating a template that would be used for the popup when a user clicks the marker
  • Created a test page that successfully queries and shows all pages in that category with Location

{{#ask: [[Category:Directory]] [[Location::+]] | format=ul | ?Image | ?Location | ?Status | template=MapProfile }}

What is not working:

  • Changing the format to a map, this results in no map at all
  • Changing the Location to convert into Coords and using "?Has Coordinates" instead of Location, this does work on the list query

What might I be missing here?

Jeroen De Dauw (talkcontribs)
Reply to "Can't seem to get Pages to show on Map"

How to install without shell access on shared hosting server for running composer

Summary by Felix Englisch

Get a fresh local install of MediaWiki, install composer locally, run composer require mediawiki/maps on your compute (in the root directory of your local mediawiki install) and upload all the directories, which where automatically installed to your local wiki, to your remote server via FTP (e.g. using Filezilla).

Felix Englisch (talkcontribs)

Don't worry, if you don't have access to the command line/terminal of your remote server. The good news is that you can nevertheless install maps on your wiki using the File Transfer Protocol (FTP/Filezilla). The bad news is that you do have to install composer on your local wiki installation.

  • OS: Windows 10
  • MW version: 1.34.1
  • PHP: 7.3.8
  • Maps extenstion: 7.20.0

The purpose of composer is that it installs all dependencies of this extension by running only one command, but if don't have access to the command line of your remote server (shell access, SSH), you cannot run it - but you can install all dependencies by hand.

To get the required directories, though, you need to get a fresh install of MediaWiki on your localhost and install composer (guide). Installing composer locally might not be the easiest task for some, but it is doable.

If the local dummy wiki is setup and composer is working, open the command line of your computer and navigate to the root directory of your local MediaWiki install (if on Windows using XAMPP, enter e.g. cd C:/xampp/htdocs/testwiki). Then, enter the following prompt: composer require mediawiki/maps

57 or so directories should be downloaded and installed automatically. Now, we only have to find these folders and upload them to right location on our remote server via FTP (e.g. using Filezilla). The directories we are looking for are in the extensions/ and the vendor/ directory of our local mediawiki install. Upload them to the exact same location (i.e. the extensions/ and vendor/ directory respectively) on our remote server. From the extensions/ folder, these are merely the folders "Maps" and "Validator". From the vendor/ directory, upload all the following folders:

bin, cache, composer (this one probably already exists in your wiki, but things changed due to the Maps installation; I've overwritten it and it worked), data-values, dnoegel, doctrine, giorgiosironi, hamcrest, jakub-onderka, jeroen, jmikola, johnkary, justinrainbow, mediawiki, monolog, myclabs, nikic, nmred, param-processor, phar-io, phpdocumentator, phpspec, phpunit, psy, sebastian, seld, squizlabs, symfony, theseer, webmozart, wildurand, wmde

Finally, add wfLoadExtension( 'Maps' ); and optionally configuration details to your your LocalSettings.php and that's it.

Reply to "How to install without shell access on shared hosting server for running composer"

Testing image layers feature in 7.17.1

Summary by Revansx

What I needed to do was this:

  • Go to page GeoJson:SensibleNameForYourMap
  • Click the create button (only shows if you have create page permissions)
  • Go back to your page with display_map and put this parameter: geojson=SensibleNameForYourMap
  • After saving the edit button to open the editor showed up.

Thank you!

Revansx (talkcontribs)

This new feature will be a much needed capability in my enterprise environment. THANK YOU!

I'm running MW 1.31 and have upgraded maps to 7.17.1 and am having difficulty getting the feature to work. Here's my experience:

  1. I visit the Special:Maps page and click on the "Add Image Overlay" button.
  2. I can now select the corners of the image overlay on the google map (development purposes only - no google account)
  3. Once the rectangular corner points are selected, I do get the dialog box asking for the details (Title, Text, and Image).
  4. I enter some text for Title and Text
  5. I enter the page name of an image I have previously uploaded as "File:Some map image.png" -- no joy
  6. I enter the page name of an image I have previously uploaded as "Some map image.png" -- no joy
  7. I enter the url to an image I have previously uploaded as "https://mywiki/w/img_auth.php/a/a1/Some map image.jpg" -- no joy

I have followed the example listed at: https://www.semantic-mediawiki.org/wiki/Maps_examples/Google_Maps_ground_overlays and it's just not working in the Special:Maps page or in a wiki page as a hand-crafted parser function

There are no errors, I just don't get the image overlay. What can I do to troubleshoot this?

Thank you!

/Rich - User:Revansx

Jeroen De Dauw (talkcontribs)

Maps has supported "image overlays" for a while. Both when using Google Maps and Leaflet. "Image overlays" just add an image on top of a normal map, as you can see on the example you linked.

The new feature (which was talked about during EMWCon) is not related to "image overlays" (besides both dealing with images). The new feature adds "image layers", which replace the base map layers. You can see an example here https://www.semantic-mediawiki.org/wiki/Extension:Maps/Leaflet#Image_layers

The new "image layers" are only supported for Leaflet, not for Google Maps. This means no integration with Special:MapEditor, which is Google Maps only. If you want visual editing on top of "image layers" you can use the new GeoJSON based visual editor.

Are you using Google Maps instead of Leaflet for some specific reason? Support for "image layers" could always be added to Google Maps as well, though that's double the work basically.

I plan to move the Maps documentation to a dedicated site/wiki soon which will hopefully make it easier to navigate.

Jeroen De Dauw (talkcontribs)

Maybe I should rename the image layers parameter to image base layers?

Revansx (talkcontribs)

ah, ok. no, i'm not using google maps for any special reason; in fact, i'd prefer not to. so thanks!..

I re-watched your EMWCon 2020 talk [1] and things are starting to make sense. I was able to generate a page called "My Map Page" with the wikitext "{{#display_map:image layer=File:My Map.jpg}}" which does render yay! :-)

So now I'm trying to figure out how to annotate it. I'll keep working at it and let you know when I get it. Any further insights you can share are much appreciated. Thanks!

[1] https://www.youtube.com/watch?v=TictndP793M

Revansx (talkcontribs)

I do have edit permissions, however, the edit button is not showing.. hmm

Revansx (talkcontribs)

is it a special right or just the normal 'edit page' right?

Revansx (talkcontribs)

'America' puts a point in Europe...

Varlin (talkcontribs)

When trying to display a simple point centered on America, with {{#display_map:locations=America|service=leaflet}}, the point is placed somewhere on Europe.

Kghbln (talkcontribs)
Varlin (talkcontribs)
Kghbln (talkcontribs)

Indeed, but even if I use Europe I get another result. I appears that it points to Paris, which would be an incorrect result even for Europe.

Jeroen De Dauw (talkcontribs)

You can use coordinates instead of "America" to precisely put the marker. "America" is rather vague, especially for a marker, so no wonder the geocoding services are giving you different results.

Jeroen De Dauw (talkcontribs)

Btw you can omit "locations="

Varlin (talkcontribs)

In my case "America" is not a hard coded input but is obtained from a database containing keywords (countries, continents...), so I can't put coordinates.

Jeroen De Dauw (talkcontribs)

I could add a new configuration setting to Maps that allows you to specify a map of place names and associated coordinates. This would then be used instead of geocoding for place names present in the map. In other words, you'd be able to specify which coordinates would be used for "America". Would this solve your problem?

Varlin (talkcontribs)

Yes it would.

Jeroen De Dauw (talkcontribs)

Request for development help - creating a map outside of MediaWiki

1 (talkcontribs)

Hi there,

Apologies for going slightly off-topic. I am part of a team of people who are developing an OpenSource project to manage the huge volunteering effort from people who want to help out neighbours who are stuck indoors because of COVID-19 ("Coronavirus").

We are very impressed by the Semantic Maps interface, and were looking to create something similar. We would be using to track the spread of our volunteering effort, by taking the lat/lon of our volunteers (with their permission), and giving them a marker of the map. The idea is that this visual representation of the success of the scheme would encourage more to get on board.

If there is anybody who has been developing Semantic Maps, and wouldn't mind lending us a hand or giving us somewhere to start from. Please do get in touch. I appreciate you are all volunteers, as are we, and we are pushing for a fast turnaround. If you are interested, please join us on Discord: discord.gg/Ej2HrDW

Thank you for your time.Request for development help - creating a map outside of MediaWiki

Maps 3.2.2 - Custom Markers Not Displayed

Tim Hoddy (talkcontribs)

Using: MediaWiki 1.24.1
PHP 5.4.16
SemanticMaps 3.1.3
Maps 3.2.2

Custom icons are not displayed here using the following:-


Where template:coords contain coodinates in the form:

51.760546, -3.572933 
~'''[[Dinas Main Crag]]'''
~51.760546, -3.572933

51.760034, -3.574529 
~'''[[Kennelgarth Wall]]'''
~51.760034, -3.574529 

51.759673, -3.577498
~'''[[Dinas - Main Slab]]'''
~51.759673, -3.577498


This works fine on Maps 2.01

Is there a way around this? Have I forgotten something?

Thanks for any help.

Varlin (talkcontribs)

Hi, after reading this thread, it seems it had been fixed around 2018, but presently I still have this issue. Am I alone in this case ? As soon as I put a "Green marker.png" the markers won't show up. Even if I do upload a file with this name on the wiki (cause I don't know where the default avaialable icons are stored).

Jeroen De Dauw (talkcontribs)
Varlin (talkcontribs)

I'm using Mediawiki 1.34, Maps 7.15.5, and I tried every different syntax possible (Green marker, Green marker.png, File:Green marker, File:Green marker.png...). Still, no marker is displayed.

Varlin (talkcontribs)

It was because the extension only looks for images stored locally and ignores settings defining shared repository for images (which is my case). See here for a fix.