GoogleMaps JSP Taglibrary  

Google:maps
Formatting Guide

Although the Google:map JSP Tag Library uses standard JSP tags to provide complete GoogleMaps™ technology, the output that results from them contains potentially large amounts of javascript/ajax and formatting.

As a result of this code it is imperative that the tags be placed in specific order on your JSP page to ensure cross-browser compatibility. While the potential places tags can go vary, it is best to stay within the guideline as they have been tested on multiple different browsers and versions.

Tag Order

The library consists of only 4 major tags which should appear in this order on your JSP page.

These tags define the data needed to create a GoogleMap:

<googlemaps:map>
This tag defines all the information needed to create a GoogleMap™. The children of this tag can be specified in any order as the data extraction is not performed until the end tag is reached. This is the parent tag of:

  • <googlemaps:box>
  • This tag is the parent tag of:
    • <googlemaps:event>
  • <googlemaps:circle>
  • This tag is the parent tag of:
    • <googlemaps:event>
  • <googlemaps:event>
  • <googlemaps:key>
  • <googlemaps:marker>
    This tag is the parent tag of:
    • <googlemaps:infowindow>
    • <googlemaps:tabbedInfoWindow>
    • This tag is parent of:
      • <googlemaps:tab>
    • <googlemaps:blowup>
    • <googlemaps:event>
    • <googlemaps:icon>
  • <googlemaps:maptype>
  • <googlemaps:message>
  • <googlemaps:overviewControl>
  • <googlemaps:panControl>
  • <googlemaps:point>
  • <googlemaps:polygon>
  • This tag is the parent tag of:
    • <googlemaps:event>
  • <googlemaps:polyline>
  • This tag is the parent tag of:
    • <googlemaps:event>
  • <googlemaps:traffic>
  • This tag is the parent tag of:
    • <googlemaps:icon>
  • <googlemaps:typeControl>
  • <googlemaps:wheelControl>
  • <googlemaps:zoomControl>

These tags generate the output to the screen using the data provided in the <googlemaps:map> tag:

<googlemaps:scripttag>
This tag generates the <script> tag that imports the correct GoogleMap™ API.
<googlemaps:javascript>
This tag generates the javascript that maps the GoogleMap™ <div> component to the various controls.
<googlemaps:div>
This tag will be the actual physical display of the GoogleMap™.
<googlemaps:initialize>
This tag generates the javascript to initialize the GoogleMap™ render it and hook it to the wheel control (ia applicable).

Tag Location

Below is the recommended location for each major tag:

<googlemaps:map>
This tag must be the first of the Google:map tags on the page. It should be placed within the <head></head> section of the JSP.
<googlemaps:javascript>
This tag should be placed within the <head></head> section of the JSP, directly after the <googlemaps:map> tag.
<googlemaps:div>
This tag can be placed any where within the <body></body> section of the JSP.
<googlemaps:initialize>
This tag should be placed immediately before the closing </body> tag, outside of any tables or formatting tags.

Miscellania

Internet Explorer Users

Internet Explorer has some unique requirements when it comes to drawing the lines on a GoogleMap™. This revolves around the use of VML. While it's not important that you understand the reasoning, it is important that if you're going to be creating maps using the GoogleMaps™ API (which includes using this tag library) that make use of polylines (which includes the <box>, <polygon>, <circle> and <polyline> tags), you will need to use the following <!DOCTYPE> and <html> tags in your JSP page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">

This will (of course) require that your page adheres to the strict XHTML standard...

Memory Leaks

Google now suggests that users of version 2 maps use the GUnload() inside their body tag to clean up any resources that might be left behind. For example:

<body ... onunload="GUnload()">

Please note that this will only work if you are using version 2 maps.

Google
Search for Google Maps technology:

Java JSP PHP ASP
Google™ and the GoogleMaps API are copyright of Google.