com.partnersoft.formats.google
Class GoogleMapBuilder

java.lang.Object
  extended by com.partnersoft.formats.google.GoogleMapBuilder

public class GoogleMapBuilder
extends java.lang.Object

Builder for Google Map html files.

No output is generated until build() is called.

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

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Rich Stepanski

Constructor Summary
GoogleMapBuilder(java.io.BufferedOutputStream out, GoogleMapLib.CreationOptions creationOption)
          Creates a new GoogleMapBuilder writing to the passed BufferedOutputStream.
GoogleMapBuilder(VfsFile destination)
          Creates a new GoogleMapBuilder writing to the passed VfsFile.
GoogleMapBuilder(VfsFile destination, GoogleMapLib.CreationOptions creationOption)
          Creates a new GoogleMapBuilder writing to the passed VfsFile.
 
Method Summary
 void addMapControl(GoogleMapLib.MapComponents component)
          Adds passed GoogleMapLib.MapComponent.
 void addMarker(double longitude, double latitude, java.lang.String styleName, java.lang.String htmlInfo)
          Adds GoogleMapMarker to this map.
 void addMarker(GoogleMapMarker marker)
          Adds GoogleMapMarker to this map.
 void addPolygon(GoogleMapPolygon polygon)
           
 void addPolygon(java.lang.String lineColor, XyPolyline line, int lineWidth, double lineOpacity, java.lang.String fillColor, double fillOpacity)
           
 void addPolyline(GoogleMapPolyline line)
           
 void addPolyline(java.lang.String lineColor, XyPolyline polyline, int lineWidth, double lineOpacity)
           
 void build()
          Generates output to specified destination.
 void setCenter(double longitude, double latitude)
          Sets the starting center position for the map.
 void setGoogleKey(java.lang.String key)
          Sets the Google Map key used to allow generated file to be viewable from a non-local location.
 void setHtmlRefresh(int htmlRefreshInSeconds)
          Sets how often the generated html file should reload itself.
 void setMapHeight(int height)
          Sets the map height in pixels.
 void setMapOption(GoogleMapLib.MapOptions option, boolean enable)
          Enables or disables the passed option based on 'enable' value.
 void setMapWidth(int width)
          Sets the map width in pixels.
 void setStyle(java.lang.String styleName, java.lang.String url)
          Maps the passed style name to the passed url.
 void setTitle(java.lang.String docName)
          Sets the title for the generated google map.
 void setZoom(double zoom)
          Sets the starting zoom for the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GoogleMapBuilder

public GoogleMapBuilder(VfsFile destination)
                 throws java.io.IOException
Creates a new GoogleMapBuilder writing to the passed VfsFile. Defaults to creating a complete html file.

Parameters:
destination - - VfsFile to write to.
Throws:
java.io.IOException - if an exception occurs creation output stream to passed destination.

GoogleMapBuilder

public GoogleMapBuilder(VfsFile destination,
                        GoogleMapLib.CreationOptions creationOption)
                 throws java.io.IOException
Creates a new GoogleMapBuilder writing to the passed VfsFile.

Parameters:
destination - - VfsFile to write to.
creationOption - - Flag determining what to build.
Throws:
java.io.IOException - if an exception occurs creation output stream to passed destination.

GoogleMapBuilder

public GoogleMapBuilder(java.io.BufferedOutputStream out,
                        GoogleMapLib.CreationOptions creationOption)
Creates a new GoogleMapBuilder writing to the passed BufferedOutputStream.

Parameters:
out - - BufferedOutputStream to write to.
creationOption - - Flag determining what to build.
Method Detail

setCenter

public void setCenter(double longitude,
                      double latitude)
Sets the starting center position for the map.

Note, if this method isn't called - the average latitude and longitude of all added objects will be used for center.

Parameters:
longitude - - initial longitude for map center.
latitude - - initial latitude for map center.

setGoogleKey

public void setGoogleKey(java.lang.String key)
Sets the Google Map key used to allow generated file to be viewable from a non-local location.

Key signup can be found at http://code.google.com/apis/maps/signup.html

Parameters:
key - - Google Map key as issued from Google.

setZoom

public void setZoom(double zoom)
Sets the starting zoom for the map.

Parameters:
zoom -

setTitle

public void setTitle(java.lang.String docName)
Sets the title for the generated google map.

Parameters:
docName -

setStyle

public void setStyle(java.lang.String styleName,
                     java.lang.String url)
Maps the passed style name to the passed url. These are the style names that any markers refer to.

Parameters:
styleName -
url -

addMapControl

public void addMapControl(GoogleMapLib.MapComponents component)
Adds passed GoogleMapLib.MapComponent.

Default map controls are LARGE_MAP_CONTROL and MAP_TYPE_CONTROL

Parameters:
component - - GoogleMapLib.MapComponent to add to map.

setMapOption

public void setMapOption(GoogleMapLib.MapOptions option,
                         boolean enable)
Enables or disables the passed option based on 'enable' value.

Parameters:
option - - GoogleMapLib.MapOptions option to enable/disable
enable - - if true, passed option is enabled. Option is disabled otherwise.

build

public void build()
           throws java.io.IOException
Generates output to specified destination.

Throws:
java.io.IOException - if an exception occurs writing output.

setMapWidth

public void setMapWidth(int width)
Sets the map width in pixels. This is the html map component width.

Parameters:
width -

setMapHeight

public void setMapHeight(int height)
Sets the map height in pixels. This is the html map component height.

Parameters:
height -

addMarker

public void addMarker(double longitude,
                      double latitude,
                      java.lang.String styleName,
                      java.lang.String htmlInfo)
Adds GoogleMapMarker to this map.

Parameters:
longitude -
latitude -
styleName -
htmlInfo -

addMarker

public void addMarker(GoogleMapMarker marker)
Adds GoogleMapMarker to this map.

Parameters:
marker -

addPolyline

public void addPolyline(java.lang.String lineColor,
                        XyPolyline polyline,
                        int lineWidth,
                        double lineOpacity)

addPolyline

public void addPolyline(GoogleMapPolyline line)

addPolygon

public void addPolygon(java.lang.String lineColor,
                       XyPolyline line,
                       int lineWidth,
                       double lineOpacity,
                       java.lang.String fillColor,
                       double fillOpacity)

addPolygon

public void addPolygon(GoogleMapPolygon polygon)

setHtmlRefresh

public void setHtmlRefresh(int htmlRefreshInSeconds)
Sets how often the generated html file should reload itself.

Parameters:
htmlRefreshInSeconds -