Introduction#

GoogleMapsPlugin is a plugin for embedding Google Maps into a JSPWiki page.

You can use it to mark certain landmarks, or to describe routes. Here's an example of how a running route was described with this plugin for a local event called Parkfestlauf-Gemmingen

The Plugin is Open Source (LGPL) -> Download Sourcecode

Installation#

  1. Download the GoogleMaps.zip and unzip it into your JSPWiki's WEB-INF directory.
  2. Edit WEB-INF/jspwiki.properties file and add org.wikiwizard.jspwiki.googlemaps to the property jspwiki.plugin.searchPath.
  3. Obtain an API key from Google Maps. Your Web URL will depend on your configuration. Usually, it should be your jspwiki.baseURL property value.
  4. Edit WEB-INF/jspwiki.properties file add the key to the property jspwiki.Google.maps.key.
  5. Optional: Edit WEB-INF/googlemaps/googlemaps.properties if you want to modify or add marker and line styles
  6. Optional: Edit your template's CSS file and define a map id such as
#map {
    min-width: 400px;
    min-height: 400px;
}

Usage#

Place the following line anywhere in a JSPWiki page.

[{GoogleMaps lat='coordinate latitude' lng='coordinate longitude'}]

Due to the nature of Google Maps, only one map is permitted per page.

Parameters#

key
Google Maps API key, now deprecated and the value is loaded from properties file
lat
Coordinate Latitude value from -90 to 90, must be enclosed in single quotation marks
lng
Coordinate Longitude value from -180 to 180, must be enclosed in single quotation marks
zoom
Zoom value from 0 to 19, where 0 is widest and 19 is closest
type
hybrid, map or sat
control
small or big
width
plugin width
height
plugin heigth
trace
values true/false - adds a trace bar at the end of the plugin to display the current lat and lng -> useful for setting new markers
fixIE
yes or no (workaround for InternetExplorer)

Defining Markers and Lines between Markers#

This is an example of two markers (points) with text in it and lines between those markers. GoogleMaps.png

Heres an example of how the above image was created:

[{GoogleMaps lat='49.12271669366686' 
             lng='9.206113815307617' 
             zoom='16' 
             width='600'
             height='400'
             type='sat'

Marker p1: 49.12271669366686, 9.206113815307617
Das [i3g Institut|http://www.i3g.hs-heilbronn.de]

Marker p2: 49.12226732260275, 9.211091995239258
Die [Hochschule|http://www.hs-heilbronn.de]

Lines:
p1 -> p2
}]

To get the coordinate, you can use Google Maps to navigate to the point you want to display, double click it so it is centered, and make note of the ll=xx.xxxx,yy.yyyy value in "Link to this page" link. They are the latitude and longitude values respectively.

Alternatively you can set the trace parameter to 'true'. This will display lat and lng at the bottom of the plugin in a yellow bar.

Additional usage#

Invisible Marker#

Invis Marker: 49.12226732260275, 9.211091995239258

Marker (default color: red)#

Marker: 49.12226732260275, 9.211091995239258

Colored Marker#

Blue Marker: 49.12226732260275, 9.211091995239258

Marker with the name "m1" (helpful to create lines)#

Marker point: 49.12226732260275, 9.211091995239258

Green Marker with the name "m2"#

Green Marker m1: 49.17226732260275, 9.211091995239258

Marker with two Tabs#

Marker: 49.12226732260275, 9.211091995239258

Tab: Tabname
Tabtext

Tab: Tabname2
Tabtext2

Line#

Lines:
49.12226732260275, 9.211091995239258 -> 49.15226732260295, 9.211091995239228

Colored Line#

Red Lines:
49.12226732260275, 9.211091995239258 -> 49.15226732260295, 9.211091995239228

Line using Marker names#

Lines:
m1 -> m2 -> 49.15226732260295, 9.211091995239228

Known Issues#

Map is not displayed (Internet Explorer)#

Somehow the plugin does not work with Internet Explorer. But there is a workaround:

  1. Add fixIE='yes' to the plugin parameters.
  2. Change the ViewTemplate.jsp of the used JSPWiki template as follows:

Insert

  <script type="text/javascript">
  //<![CDATA[
  
  function checkgooglemaps(){
  	if ( window.googlemaps )
  	{
  		googlemaps()
  	}
  }
  //]]>
  </script>

into the <head> section of the page. Then add an onload parameter to the <body> tag:

<body class="view" bgcolor="#FFFFFF" onload="checkgooglemaps()">

This should solve the problem. If anyone knows a better solution, please let us know (just add a comment below). It seems IE has a problem with directly executing the javascript code. But it works when putting all code into a function and executing it from onload.

Map is not displayed (Internet Explorer) part 2:#

The above solution prevents (?) the window.onload call in commonheaders.jsp (breaking TabbedSection, SearchBox, Sortable, ZebraTable... etc.). The following solution works for me (2007-Jan-12, RonAtkins):
  1. Follow the directions in the section Lines and overview map are not displayed (below, to resolve lines not being displayed in IE).
  2. Add fixIE='yes' to the plugin parameters.
  3. Make the following changes in commonheader.jsp (of the JSPWiki template you are using):
<%-- Here we define the "run when the page loads" -script. --%>
<script type="text/javascript">

function checkgooglemaps()
{
  	if ( window.googlemaps )
  	{
  		googlemaps();
  	}
}

function runOnLoad()
{ 
  TabbedSection.onPageLoad();
  SearchBox.onPageLoad();
  Wiki.onPageLoad();
  Sortable.onPageLoad();
  ZebraTable.onPageLoad();
  HighlightWord.onPageLoad();
  Collapsable.onPageLoad();
  GraphBar.onPageLoad();
  checkgooglemaps();
  <wiki:IncludeResources type="jsfunction"/>
}

window.onload = runOnLoad;

</script>

Lines and overview map are not displayed (Internet Explorer)#

Even using the workaround for the IE problem, lines and the minmap are not displayed when using IE. The solution is described on the Google Maps API page: http://www.google.com/apis/maps/documentation/#XHTML_and_VML. The changes also have to be made in the ViewTemplate.jsp file.

History#

This Plugin was implemented independently by the i3G Institute and msb0b.com.

The Plugin as described above is a semester work by Amir Farokhzad done at the i3G Institute.

The plugin by msb0b.com was published on this page three days before Amir Farokhzads Plugin, but the msb0b.com implementation is very basic an therefore is lacking several features

  • User-defined map type
  • Point information
  • Multiple points
  • Connect the points with lines

The msb0b.com Implementation is attached on this page. -> GoogleMapsPlugin.java(info) and GoogleMapsPlugin.jar(info).

Please visit the project page of msb0b.com for more details.

14-Jun-2006 --ChristophSauer


super!!!!

--Fan Wang, 15-Jul-2006


I followed your guide step by step, but

Plugin insertion failed: Plugin failed ?

why?

My wiki is 2.4.53

--AnonymousCoward, 24-Sep-2006

The plugins seems to need Java 5... Also there is a little typo error which makes pop-up ballons go werk (javascript errors pop up). Specifically, in GoogleMaps.java, line 289 should look like this:

map += "  document.getElementById(\"zoom\").innerHTML = map.getZoom()\n";

also, as you fix this in the source code, ballons appear without content. In tomcat's stdout you can see that data is correctly retrieved but it's not shown in the G'Map

-- JP 02/10/2006

Update: I've been looking through the code. Wiki2HTMLConverter was using TranslatorReader which is deprecated since 2.3 so, when parsing text into Tabs you always got a blank String. Fixed the code for 2.4.x (thanks Janne for pointing here for instructions on how to parse wiki markup in 2.4). I've also corrected the small typo noted yesterday and removed all System.out's, as debugging with Eclipse is a lot easier if you want to follow the code.

This jar has been tested on 2.4.64, compiled and uploaded to this page with the source code. Download the plugin for 2.4 branch clicking here(info). The zip has the source code and the compiled jar (it's in the ./bin folder). For installing it, take that jar and follow the previous instructions (place it in WEB-INF/lib, etc)

-- JP 03/10/2006

I wanted to use this on a machine that only had Java 1.4 on it, so has to replace some Java 5 functions that were being used with some 1.4 equivalents.

  • String.replace(String regex, String text) became String.replaceAll(String regex, String text)
  • String.contains(String needle) became String.indexOf(String needle)>=0

This patch(info) is against the 2.4.64(info) branch below.

To apply the patch and recompile.

unzip googlemaps-plugin-2.4.64.zip
cd googlemaps
patch -p1 < path/to/java1.4_patch_for_googlemaps-plugin-2.4.64
rm -Rf bin/org/
javac -d bin -classpath /path/to/apache-tomcat/common/lib/servlet-api.jar:/path/to/apache-tomcat/webapps/JSPWiki/WEB-INF/lib/JSPWiki.jar src/org/wikiwizard/jspwiki/googlemaps/*.java
cd bin/
rm googlemaps.jar 
zip googlemaps.jar -r .

then install the jar as normal (place it in WEB-INF/lib, etc)

-- Jonathan 2006/12/03

I followed the install step by step. But I got the following problem.

Plugin insertion failed: Could not find plugin GoogleMaps

I modify jspwiki.propertires file as the following:

jspwiki.plugin.searchPath =org.wikiwizard.jspwiki.googlemaps

jspwiki.Google.maps.key=XXXXXX

XXXXXX is Google Maps key number.

Does any get the same proble? My JSPWiki version is v2.8.1.

-- TonyChou 2009/03/17


That's what I get from the Parkfestlauf-Gemmingen example: Plugin insertion failed: Could not find plugin org.wikiwizard.jspwiki.googlemaps.GoogleMaps

--Rolf Schumacher, 23-Dec-2009 22:53

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
jpg
001.jpg 162.7 kB 1 28-May-2009 17:01 94.25.4.114
png
GoogleMaps.png 269.0 kB 3 15-Jun-2006 10:25 Christoph Sauer
jar
GoogleMapsPlugin.jar 2.3 kB 1 12-Jun-2006 13:45 msb0b
java
GoogleMapsPlugin.java 5.0 kB 1 12-Jun-2006 13:45 msb0b
zip
googlemaps-plugin-2.4.64.zip 59.2 kB 1 03-Oct-2006 12:10 213.96.121.208
64
java1.4_patch_for_googlemaps-p... 2.9 kB 1 03-Dec-2006 01:24 203.206.126.157 patch against googlemaps-plugin-2.4.64.zip to support java1.4
« This page (revision-53) was last changed on 23-Dec-2009 22:55 by Rolf Schumacher