com.partnersoft.formats.google
Class GoogleMapWriter

java.lang.Object
  extended by com.partnersoft.formats.xml.XmlBuilder
      extended by com.partnersoft.formats.xml.HtmlBuilder
          extended by com.partnersoft.formats.google.GoogleMapWriter

public class GoogleMapWriter
extends HtmlBuilder

A writer for creating both html and javascript for a google map page. All method calls result in direct output to output stream.

See also com.partnersoft.formats.google.GoogleMapBuilder.

Note, the order items are added to the GMap2 object will have an affect on the page. It seems controls must be added after all items have been overlaid, and no methods can be called on the map object until setCenter has been called.

Reference at: http://code.google.com/apis/maps/documentation/

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Rich Stepanski

Field Summary
static java.lang.String DOCTYPE
           
static java.lang.String GOOGLESOURCE
           
static java.lang.String XMLNS
           
 
Fields inherited from class com.partnersoft.formats.xml.HtmlBuilder
embeddedcss
 
Constructor Summary
GoogleMapWriter(java.io.OutputStream out)
          Creates a new GoogleMapWriter outputting to the passed stream.
GoogleMapWriter(VfsFile dest)
          Creates a new GoogleMapWriter outputting to the passed writer.
GoogleMapWriter(java.io.Writer writer)
          Creates a new GoogleMapWriter outputting to the passed writer.
 
Method Summary
 void addIcon(java.lang.String iconName, java.lang.String iconUrl)
          Defines a new GIcon to be used later.
 void addMapControls(java.util.List<GoogleMapLib.MapComponents> components)
          Adds all passed MapComponents to the GMap2 object in javascript.
 void addMarker(GoogleMapMarker marker)
          Adds a new GMarker to the map.
 void addPolygon(GoogleMapPolygon polygon)
          Adds a new GPolygon to the map.
 void addPolyline(GoogleMapPolyline polyline)
          Adds a new GPolyline to the map.
 void createMap()
          Creates Google Map (GMap2 javascript) object with document id 'map'.
 void createMap(java.lang.String mapName)
          Creates Google Map object (GMap2 javascript) with using passed document id.
 void endBody()
           
 void setMapCenter(double longitude, double latitude, int zoom)
          Sets center of map.
 void setMapOption(GoogleMapLib.MapOptions option, boolean isEnabled)
          Writes javascript for enabling or disabling the passed Google Map Option.
 void setZoom(int zoom)
           
 void startBody()
          Writes a body tag with onload, onunload properties set.
 void startBody(java.lang.String hexBgColor)
          Writes a body tag with onload, onunload, and bgcolor properties set.
 void startDocument(java.lang.Object documentName)
          Sets up intial html tags for GoogleMap generation.
 void writeGoogleKey(java.lang.String googleKey)
          Writes Script tag containing GoogleMap key.
 
Methods inherited from class com.partnersoft.formats.xml.HtmlBuilder
endBulletedList, endDocument, endListItem, endNumberedList, endTable, endTableData, endTableRow, h1, h2, h3, h4, h5, hr, p, startBulletedList, startListItem, startNumberedList, startTable, startTableData, startTableRow, tableContents, tableHeader, writeBulletedList, writeLink, writeListItem, writeMapAsTable, writeParagraph, writeStackTrace
 
Methods inherited from class com.partnersoft.formats.xml.XmlBuilder
beginStartTag, close, endElement, endElement, endElement, endElement, endStartTag, isDroppingElementsWithoutContent, isEmptyingElementsWithoutContent, setDroppingElementsWithoutContent, setEmptyingElementsWithoutContent, startElement, startElement, startElement, writeAttribute, writeContent, writeContent, writeElement, writeElement, writeElement, writeEmptyElement, writeIterableContent, writeRaw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCTYPE

public static final java.lang.String DOCTYPE
See Also:
Constant Field Values

XMLNS

public static final java.lang.String XMLNS
See Also:
Constant Field Values

GOOGLESOURCE

public static final java.lang.String GOOGLESOURCE
See Also:
Constant Field Values
Constructor Detail

GoogleMapWriter

public GoogleMapWriter(java.io.OutputStream out)
                throws java.io.IOException
Creates a new GoogleMapWriter outputting to the passed stream.

Parameters:
out - - where to write.
Throws:
java.io.IOException

GoogleMapWriter

public GoogleMapWriter(java.io.Writer writer)
                throws java.io.IOException
Creates a new GoogleMapWriter outputting to the passed writer.

Parameters:
writer - - Where to write.
Throws:
java.io.IOException

GoogleMapWriter

public GoogleMapWriter(VfsFile dest)
                throws java.io.IOException
Creates a new GoogleMapWriter outputting to the passed writer.

Parameters:
dest - - where to write.
Throws:
java.io.IOException
Method Detail

startDocument

public void startDocument(java.lang.Object documentName)
                   throws java.io.IOException
Sets up intial html tags for GoogleMap generation.

Sets doctype. Opens html and sets xmlns. Sets head and sets meta (content-type) Sets title.

End result, unclosed html tag with unclosed head tag.

Overrides:
startDocument in class HtmlBuilder
Throws:
java.io.IOException

writeGoogleKey

public void writeGoogleKey(java.lang.String googleKey)
                    throws java.io.IOException
Writes Script tag containing GoogleMap key. This is required if file is to be used in a non-local way.

Parameters:
googleKey -
Throws:
java.io.IOException

startBody

public void startBody()
               throws java.io.IOException
Writes a body tag with onload, onunload properties set. onload = load() and onunload = GUnload.

Throws:
java.io.IOException

startBody

public void startBody(java.lang.String hexBgColor)
               throws java.io.IOException
Writes a body tag with onload, onunload, and bgcolor properties set. onload = load() and onunload = GUnload.

Parameters:
hexBgColor -
Throws:
java.io.IOException

endBody

public void endBody()
             throws java.io.IOException
Throws:
java.io.IOException

createMap

public void createMap(java.lang.String mapName)
               throws java.io.IOException
Creates Google Map object (GMap2 javascript) with using passed document id. Note, before the map can be used in anyway - setMapCenter must be called.

Parameters:
mapName - - id of map in html.
Throws:
java.io.IOException

createMap

public void createMap()
               throws java.io.IOException
Creates Google Map (GMap2 javascript) object with document id 'map'. Note, before the map can be used in anyway - setMapCenter must be called.

Throws:
java.io.IOException

setMapOption

public void setMapOption(GoogleMapLib.MapOptions option,
                         boolean isEnabled)
                  throws java.io.IOException
Writes javascript for enabling or disabling the passed Google Map Option. Note, the GMap2 object must already have been defined in the javascript.

Parameters:
option -
isEnabled -
Throws:
java.io.IOException

addMapControls

public void addMapControls(java.util.List<GoogleMapLib.MapComponents> components)
                    throws java.io.IOException
Adds all passed MapComponents to the GMap2 object in javascript. The map must of already been created.

Default map controls are LARGE_MAP_CONTROL and MAP_TYPE_CONTROL Controls must be added after any overlays are added.

Parameters:
components -
Throws:
java.io.IOException

setMapCenter

public void setMapCenter(double longitude,
                         double latitude,
                         int zoom)
                  throws java.io.IOException
Sets center of map. Must be called after createMap() before any map can be used for anything else. (ie, adding controls etc)

Parameters:
longitude -
latitude -
Throws:
java.io.IOException

setZoom

public void setZoom(int zoom)
             throws java.io.IOException
Throws:
java.io.IOException

addIcon

public void addIcon(java.lang.String iconName,
                    java.lang.String iconUrl)
             throws java.io.IOException
Defines a new GIcon to be used later. Assigns the icon's image to the passed url image. (javascript)

Parameters:
iconName - - var name.
iconUrl - - icon url.
Throws:
java.io.IOException

addMarker

public void addMarker(GoogleMapMarker marker)
               throws java.io.IOException
Adds a new GMarker to the map. The GMap2 object must already be defined in javascript.

Parameters:
marker -
Throws:
java.io.IOException

addPolygon

public void addPolygon(GoogleMapPolygon polygon)
                throws java.io.IOException
Adds a new GPolygon to the map. The GMap2 object must already be defined in javascript.

Parameters:
polygon -
Throws:
java.io.IOException

addPolyline

public void addPolyline(GoogleMapPolyline polyline)
                 throws java.io.IOException
Adds a new GPolyline to the map. The GMap2 object must already be defined in javascript.

Parameters:
polyline -
Throws:
java.io.IOException