Extension talk:Google Maps/Syntax

From mediawiki.org

Can someone tell how to exactly use custom icons[edit]

>> You can host your own collection of icons on your server, but note that they'll have the same >> anchor points as Google's default icon

Can someone tell how to exactly use custom icons? I have downloaded a set and have them in a folder on the site. Where does the icons attribute go?

I wanna know, too. See below.

how to use multiple icons?[edit]


Does anyone know how to use multiple icons? I want to use 4 different coloured icons to distinguish between the different locations on the map.

SoftDux 16:23, 23 March 2007 (UTC)Reply[reply]

Try something like this:

<googlemap lat="51.978113" lon="5.306396" type="map" zoom="7" width="400" height="500">
(H) 52.034277, 5.167522, Houten
(O) 52.053321, 5.23972, Odijk

Vic, 11:09, 12 June 2007 (UTC)

Thanx, that helped a bit :)

Now I just need to figure out how to get the icons to "auto display" when I hover over them, instead of having to click on each one

Have you found out how to autodisplay them? 09:12, 10 July 2007 (UTC) en:User:JanCK
How about your own icons? how do you add multiple icons to the googlemap tag using "icons"? 06:18, 27 April 2010 (UTC)Reply[reply]

my own icon set[edit]

You can host your own collection of icons on your server, but note that they'll have the same anchor points as Google's default icon.

What's that syntax for icons at my own server? I tried
  (http://myserver.com/mypicture.gif) 52.053321, 5.23972, Odijk


http://myserver.com/mypicture.gif 52.053321, 5.23972, Odijk

both didn't work. Maybe I may not use gifs, or a specific size is required? 09:12, 10 July 2007 (UTC) en:User:JanCK

I just had a look at the source code and I don't see how it could work. It first checks whether the line you wrote matches

 preg_match("/^(?:\(([.a-zA-Z0-9_-]*?)\) *)?([^,]+), *([^ ,]+)(?:, (.+))?/", $line, $matches))

Anyone familiar with RegExp? Would

  (http://myserver.com/mypicture.gif) 52.053321, 5.23972, Odijk

match this pattern? The other two alternatives, that are checked, are:

 preg_match('/^\/([^\\\\]+)\\\\ *(.*)$/', $line, $matches))

for tabs and

 preg_match("/^(#[0-9a-fA-F]{6})/", $line, $matches))

for polygon lines. With

 $o = array("icons" => "http://maps.google.com/mapfiles/marker{label}.png",    "icon" => "http://www.google.com/mapfiles/marker.png",    );

It goes on:

 $output .= googleMaps_AddMarker($lat, $lon, $icon, 'SMALLERTHANdiv style="direction: rtl;">'.$parsed->getText().'SMALLERTHAN/div>', $color, $tabs);
 $icon = $matches[1];
 if ($icon && !$icons[$icon]) { // need to create this icon, since we haven't already
  $output .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '".addslashes(str_replace("{label}", $icon, $o['icons']))."');";
  $icons[$icon] = true;
 $output .= " marker = new GMarker(new GLatLng({$lat}, {$lon}), { 'icon':mapIcons['{$icon}'], 'clickable':false });";


It seem to me that

 if ($icon && !$icons[$icon]) { // need to create this icon, since we haven't already
  $output .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '".addslashes(str_replace("{label}", $icon, $o['icons']))."');";
  $icons[$icon] = true;

should be replaced with something like

 if (preg_match("/^([A-Z])/", $icon, $null) && !$icons[$icon]) { // need to create this icon, since we haven't already
  $output .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '".addslashes(str_replace("{label}", $icon, $o['icons']))."');";
  $icons[$icon] = true;
 } elseif
   if (&icon && !$icons[$icon]) { // need to create this icon, since we haven't already
    $output .= " mapIcons['{$icon}'] = new GIcon(G_DEFAULT_ICON, '".addslashes($icon)."');";
    $icons[$icon] = true;

But I haven't tried it, nor do I know whether an array allows an arbitrary string as indexing argument. 09:55, 10 July 2007 (UTC) en:User:JanCK

Try this (tested)[edit]

  if( $icon ){
     if (!isset($icons[$icon])) $icons[$icon] = false;
     if (!$icons[$icon]) {
        $exporter->addIcon($icon, $o);
        $icons[$icon] = true;

This seems to work for me. 10:07, 18 Sept 2008 (UTC) en:User:Nathan Gardiner

Furthermore, I guess the regular expression doesn't allow :// , so probably that's gotta be changed, too.


Oh, I think I got it! You are not supposed to mix your icons with googles icons. You specify icons="http://myserver.com/marker{label}.png" and icons="http://myserver.com/marker.png" into the googlemaps tag and you'll than only use your own icons. 10:07, 10 July 2007 (UTC) en:User:JanCK

how to print the map + direction and way points[edit]

Hi all,

if i print an page with a map + way points or direction on it, the map is ok but there is no direction or way point printed, what do?


Custom Underlying Map[edit]

hey All i am developing a site for personal development and user usage but have come across very limited available for custom maps. I am looking to implement a custom map that is not geo-spatial nor is it a space map. It is a custom map that i am compiling from a game and have yet to find a solution that will allow me to upload my own rastered map for drilling into for detail perspective. I have found one site that has one ability but requires me to create a reference link to their site which increases the page load time. I need to have a rastered map image and then overlay GoogleMaps utility ontop of it for the drill down effect. As well i am looking to use the functionality of googlemaps for tagging and line developement ontop of this rastered image.

If any of you have an idea on this please direct me. I am currently using MapLib as my host renderer but it is limited in its ability due to page load time.

Using Alphabet markers breaks KML file...?[edit]


If I make a marker like this:

(S) 42.711618, -73.205112

And then implement the KML file link, the resulting KML loads with an error about having no root element.

If I take the (S) away, the resulting KML file loads absolutely fine in Google Earth.

Is this a bug?

Thanks 03:46, 30 May 2008 (UTC)Reply[reply]

Converting KML markup to wikicode?[edit]

I may not understand KML documents correctly but I am looking for a way to convert KML markup to Mediwiki code, not just to parse the document and have it display. Any extensions or tutiorals out there? I only could find a KML Export which coverts the wrong way for me. We would like to able to have users expand existing map point data and add new map points.

And one more thing... it appears that tabbing does not work correctly in Mediawiki 1.11.0 (at least not for me). The last tab is alway blank. So if I create 2 tabs, Tab One has content, Tab Two is blank. If I create 3 tabs, Tab One has content, Tab Two has content and Tab Three is blank, etc....
Hopefully this will be corrected when I upgrade to 1.12.0

Myotus 16:09, 7 August 2008 (UTC)Reply[reply]

How to Query with the name of the Location?[edit]

Google maps accepts queries with direct geographic entry. Is there any implementation in this extension that enables users to invoke map retrievals without coordinates but only names? Regards-- 17:43, 29 September 2008 (UTC)Reply[reply]

I could use something like this too. I'm trying to set up a template that generates a googlemap for live music venues. I'd like to feed the venue name and city name into the template params, and generate a google map of it.-- 17:42, 19 August 2009 (UTC)Reply[reply]

empty info windows shown[edit]

Hi everyone, I had the following problem. When using the code

<googlemap version="0.9" lat="48.764676" lon="8.235669" zoom="15">
(A) 48.760913, 8.237429

I got a map with one marker "A" that had a defined onclick event, although there is no title and no caption defined. When clicking the marker an empty info window opened. I read the code and found the important part in file: GoogleMapsJsExporter.php. There is a function addMarker() and in this function there is a variable $captionNoNewlines. I found out that the Mediawiki parser is rendering some "limit report" as a comment into this variable. The GoogleMaps Extension then thinks that the variable is not empty and adds an (empty) infowindow to the marker.

My work around is as follows: I added the lines marked with '//MG' to the addMarker() function:

if (is_string($pCaption)) {
  $captionNoNewlines = preg_replace('/[\r\n]+/', ' ', $pCaption);
  $captionNoNewlines = preg_replace('//s', ' ', $captionNoNewlines); //MG
  $captionNoNewlines = trim($captionNoNewlines); //MG

These two lines remove the limit report comment and possibly existing whitespace characters at the beginning and at the end of $captionNoNewlines.

This is only a workaround! It would be better to tell the parser to not render this limit report at all. There is a method ParserOptions::enableLimitReport ( $x = true ). I just don't know how to apply this method. Perhaps someone else knows?

MG 09:55, 29 June 2010 (UTC)Reply[reply]

MW 1.6 and paths[edit]

is there a way to enable colored paths on MW 1.6? Thanks 10:05, 1 September 2010 (UTC)Reply[reply]

Showing Labels by Default in Satellite View[edit]

Is there a way to have "Show labels" on by default on a map? I can set type="satellite", but I haven't found a way to set the road labels to 'on' by default. Thanks! Satri 14:30, 18 November 2010 (UTC)Reply[reply]