com.google.gwt.maps.client.overlay
Class Polyline

java.lang.Object
  extended by com.google.gwt.maps.client.overlay.Overlay
      extended by com.google.gwt.maps.client.overlay.Overlay.ConcreteOverlay
          extended by com.google.gwt.maps.client.overlay.Polyline

public class Polyline
extends Overlay.ConcreteOverlay

This is a map overlay that draws a polyline on the map, using the vector drawing facilities of the browser if they are available, or an image overlay from Google servers otherwise.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.maps.client.overlay.Overlay
Overlay.ConcreteOverlay
 
Field Summary
 
Fields inherited from class com.google.gwt.maps.client.overlay.Overlay
jsoPeer
 
Constructor Summary
protected Polyline(com.google.gwt.core.client.JavaScriptObject jsoPeer)
          Create this polyline from an existing JavaScriptObject instance.
  Polyline(LatLng[] points)
          Create a new polyline.
  Polyline(LatLng[] points, java.lang.String color)
          Create a new polyline.
  Polyline(LatLng[] points, java.lang.String color, int weight)
          Create a new polyline.
  Polyline(LatLng[] points, java.lang.String color, int weight, double opacity)
          Create a new polyline.
  Polyline(LatLng[] points, java.lang.String color, int weight, double opacity, PolylineOptions options)
          Create a new polyline.
 
Method Summary
 void addPolylineCancelLineHandler(PolylineCancelLineHandler handler)
          This event is fired when the polyline is being edited and the edit is canceled.
 void addPolylineClickHandler(PolylineClickHandler handler)
          This event is fired when the polyline is clicked.
 void addPolylineEndLineHandler(PolylineEndLineHandler handler)
          This event is fired when the polyline is being edited and the edit is completed.
 void addPolylineLineUpdatedHandler(PolylineLineUpdatedHandler handler)
          This event is fired when the polyline has a vertex inserted.
 void addPolylineMouseOutHandler(PolylineMouseOutHandler handler)
          This event is fired when the mouse moves out of a polyline.
 void addPolylineMouseOverHandler(PolylineMouseOverHandler handler)
          This event is fired when the mouse moves over a polyline.
 void addPolylineRemoveHandler(PolylineRemoveHandler handler)
          This event is fired when the polyline is removed from the map, using MapWidget.removeOverlay(com.google.gwt.maps.client.overlay.Overlay) or MapWidget.clearOverlays().
 void addPolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler handler)
          This event is fired when the polyline is clicked.
static Polyline createPeer(com.google.gwt.core.client.JavaScriptObject jsoPeer)
          Used to create a new Polyline by wrapping an existing GPolyline object.
 void deleteVertex(int index)
          Removes the vertex with the given index in the polyline and updates the shape of the polyline accordingly.
static Polyline fromEncoded(EncodedPolyline polyline)
          Create a polyline from an encoded string.
static Polyline fromEncoded(java.lang.String color, int weight, double opacity, java.lang.String encodedPoints, int zoomFactor, java.lang.String encodedLevels, int numLevels)
          Create a polyline from an encoded string.
static Polyline fromEncoded(java.lang.String encodedPoints, int zoomFactor, java.lang.String encodedLevels, int numLevels)
          Create a polyline from an encoded string.
 LatLngBounds getBounds()
          Returns the bounds for this polyline.
 double getLength()
          Returns the length (in meters) of the polyline along the surface of a spherical Earth.
 LatLng getVertex(int index)
          Returns the vertex with the given index in the polyline.
 int getVertexCount()
          Returns the number of vertices in the polyline.
 void insertVertex(int index, LatLng latlng)
          Inserts a new point at the given index in the polyline and updates its shape.
 boolean isVisible()
          Returns true if the polyline is visible on the map.
 void removePolylineCancelLineHandler(PolylineCancelLineHandler handler)
          Removes a single handler of this map previously added with addPolylineCancelLineHandler(PolylineCancelLineHandler).
 void removePolylineClickHandler(PolylineClickHandler handler)
          Removes a single handler of this map previously added with addPolylineClickHandler(PolylineClickHandler).
 void removePolylineEndLineHandler(PolylineEndLineHandler handler)
          Removes a single handler of this map previously added with addPolylineEndLineHandler(PolylineEndLineHandler).
 void removePolylineLineUpdatedHandler(PolylineLineUpdatedHandler handler)
          Removes a single handler of this map previously added with addPolylineLineUpdatedHandler(PolylineLineUpdatedHandler).
 void removePolylineMouseOutHandler(PolylineMouseOutHandler handler)
          Removes a single handler of this map previously added with addPolylineMouseOutHandler(PolylineMouseOutHandler).
 void removePolylineMouseOverHandler(PolylineMouseOverHandler handler)
          Removes a single handler of this map previously added with addPolylineMouseOverHandler(PolylineMouseOverHandler).
 void removePolylineRemoveHandler(PolylineRemoveHandler handler)
          Removes a single handler of this map previously added with addPolylineRemoveHandler(PolylineRemoveHandler).
 void removePolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler handler)
          Removes a single handler of this map previously added with addPolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler) .
 void setDrawingEnabled()
          Allows a user to construct (or modify) a GPolyline object by clicking on additional points on the map.
 void setDrawingEnabled(PolyEditingOptions opts)
          Enable drawing as in setDrawingEnabled() but with control over the polyline drawing parameters.
 void setEditingEnabled(boolean enabled)
          Allows modification of an existing Polyline chain of points.
 void setEditingEnabled(PolyEditingOptions opts)
          Enable editing as in setEditingEnabled(boolean), but with control over the polyline drawing parameters.
 void setStrokeStyle(PolyStyleOptions style)
          Changes the style of the polyline.
 void setVisible(boolean visible)
          Show or hide the polyline.
 boolean supportsHide()
          Returns true if this environment supports the setVisible(boolean) method.
 
Methods inherited from class com.google.gwt.maps.client.overlay.Overlay.ConcreteOverlay
copy, initialize, redraw, remove
 
Methods inherited from class com.google.gwt.maps.client.overlay.Overlay
getZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polyline

public Polyline(LatLng[] points)
Create a new polyline.

Parameters:
points - An array of points to use as verticies for the Polyline.

Polyline

public Polyline(LatLng[] points,
                java.lang.String color)
Create a new polyline.

Parameters:
points - An array of points to use as verticies for the Polyline.
color - color a string that contains a hexadecimal numeric HTML style, i.e. #RRGGBB

Polyline

public Polyline(LatLng[] points,
                java.lang.String color,
                int weight)
Create a new polyline.

Parameters:
points - An array of points to use as verticies for the Polyline.
color - a string that contains a hexadecimal numeric HTML style, i.e. #RRGGBB
weight - the width of the line in pixels. opacity is a number between 0 and 1.

Polyline

public Polyline(LatLng[] points,
                java.lang.String color,
                int weight,
                double opacity)
Create a new polyline.

Parameters:
points - An array of points to use as verticies for the Polyline.
color - a string that contains a hexadecimal numeric HTML style, i.e. #RRGGBB
weight - the width of the line in pixels. opacity is a number between 0 and 1.
opacity - a number between 0 and 1.0 where 1.0 is totally opaque.

Polyline

public Polyline(LatLng[] points,
                java.lang.String color,
                int weight,
                double opacity,
                PolylineOptions options)
Create a new polyline.

Parameters:
points - An array of points to use as verticies for the Polyline.
color - a string that contains a hexadecimal numeric HTML style, i.e. #RRGGBB
weight - the width of the line in pixels. opacity is a number between 0 and 1.
opacity - a number between 0 and 1.0 where 1.0 is totally opaque.

Polyline

protected Polyline(com.google.gwt.core.client.JavaScriptObject jsoPeer)
Create this polyline from an existing JavaScriptObject instance.

Parameters:
jsoPeer - an existing JavaScriptObject instance.
Method Detail

createPeer

public static Polyline createPeer(com.google.gwt.core.client.JavaScriptObject jsoPeer)
Used to create a new Polyline by wrapping an existing GPolyline object. This method is invoked by the jsio library.

Parameters:
jsoPeer - GPolyline object to wrap.
Returns:
a new instance of Polyline.

fromEncoded

public static Polyline fromEncoded(EncodedPolyline polyline)
Create a polyline from an encoded string. Details of the encoding is described on the Google Maps developer web site.

Parameters:
polyline - An object containing all the information for the new polyline.
Returns:
a new Polyline constructed from the object.

fromEncoded

public static Polyline fromEncoded(java.lang.String color,
                                   int weight,
                                   double opacity,
                                   java.lang.String encodedPoints,
                                   int zoomFactor,
                                   java.lang.String encodedLevels,
                                   int numLevels)
Create a polyline from an encoded string. Details of the encoding is described on the Google Maps developer web site.

Parameters:
color - See EncodedPolyline.setColor(String)
weight - See EncodedPolyline.setWeight(int)
opacity - See EncodedPolyline.setOpacity(double)
encodedPoints - See EncodedPolyline.setPoints(String)
zoomFactor - See EncodedPolyline.setZoomFactor(int)
encodedLevels - See EncodedPolyline.setLevels(String)
numLevels - See EncodedPolyline.setNumLevels(int)
Returns:
a new Polyline constructed from the string.

fromEncoded

public static Polyline fromEncoded(java.lang.String encodedPoints,
                                   int zoomFactor,
                                   java.lang.String encodedLevels,
                                   int numLevels)
Create a polyline from an encoded string. Details of the encoding is described on the Google Maps developer web site.

Parameters:
encodedPoints - See EncodedPolyline.setPoints(String)
zoomFactor - See EncodedPolyline.setZoomFactor(int)
encodedLevels - See EncodedPolyline.setLevels(String)
numLevels - See EncodedPolyline.setNumLevels(int)
Returns:
a new Polyline constructed from the string.

addPolylineCancelLineHandler

public void addPolylineCancelLineHandler(PolylineCancelLineHandler handler)
This event is fired when the polyline is being edited and the edit is canceled. See setEditingEnabled(boolean)

Parameters:
handler - the handler to call when this event fires.

addPolylineClickHandler

public void addPolylineClickHandler(PolylineClickHandler handler)
This event is fired when the polyline is clicked. Note that this event also subsequently triggers a "click" event on the map, where the polyline is passed as the overlay argument within that event.

Parameters:
handler - the handler to call when this event fires.

addPolylineEndLineHandler

public void addPolylineEndLineHandler(PolylineEndLineHandler handler)
This event is fired when the polyline is being edited and the edit is completed. See setEditingEnabled(boolean)

Parameters:
handler - the handler to call when this event fires.

addPolylineLineUpdatedHandler

public void addPolylineLineUpdatedHandler(PolylineLineUpdatedHandler handler)
This event is fired when the polyline has a vertex inserted. See insertVertex(int,LatLng)

Parameters:
handler - the handler to call when this event fires.

addPolylineMouseOutHandler

public void addPolylineMouseOutHandler(PolylineMouseOutHandler handler)
This event is fired when the mouse moves out of a polyline.

Parameters:
handler - the handler to call when this event fires.

addPolylineMouseOverHandler

public void addPolylineMouseOverHandler(PolylineMouseOverHandler handler)
This event is fired when the mouse moves over a polyline.

Parameters:
handler - the handler to call when this event fires.

addPolylineRemoveHandler

public void addPolylineRemoveHandler(PolylineRemoveHandler handler)
This event is fired when the polyline is removed from the map, using MapWidget.removeOverlay(com.google.gwt.maps.client.overlay.Overlay) or MapWidget.clearOverlays().

Parameters:
handler - the handler to call when this event fires.

addPolylineVisibilityChangedHandler

public void addPolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler handler)
This event is fired when the polyline is clicked. Note that this event also subsequently triggers a "click" event on the map, where the polyline is passed as the overlay argument within that event

Parameters:
handler - the handler to call when this event fires.

deleteVertex

public void deleteVertex(int index)
Removes the vertex with the given index in the polyline and updates the shape of the polyline accordingly. The Polyline must already be added to the map via MapWidget.addOverlay(Overlay).


getBounds

public LatLngBounds getBounds()
Returns the bounds for this polyline.

Returns:
the bounds for this polyline.

getLength

public double getLength()
Returns the length (in meters) of the polyline along the surface of a spherical Earth.

Returns:
the length (in meters) of the polyline along the surface of a spherical Earth.

getVertex

public LatLng getVertex(int index)
Returns the vertex with the given index in the polyline.

Parameters:
index - the index in the polyline to query.
Returns:
the point represented by the specified index.

getVertexCount

public int getVertexCount()
Returns the number of vertices in the polyline.

Returns:
the number of vertices in the polyline.

insertVertex

public void insertVertex(int index,
                         LatLng latlng)
Inserts a new point at the given index in the polyline and updates its shape. The Polyline must already be added to the map via MapWidget.addOverlay(Overlay).

Parameters:
index - the index into the polyline at which to insert this point.
latlng - the value of the point to add.

isVisible

public boolean isVisible()
Returns true if the polyline is visible on the map.

Returns:
true if the polyline is visible on the map.

removePolylineCancelLineHandler

public void removePolylineCancelLineHandler(PolylineCancelLineHandler handler)
Removes a single handler of this map previously added with addPolylineCancelLineHandler(PolylineCancelLineHandler).

Parameters:
handler - the handler to remove

removePolylineClickHandler

public void removePolylineClickHandler(PolylineClickHandler handler)
Removes a single handler of this map previously added with addPolylineClickHandler(PolylineClickHandler).

Parameters:
handler - the handler to remove.

removePolylineEndLineHandler

public void removePolylineEndLineHandler(PolylineEndLineHandler handler)
Removes a single handler of this map previously added with addPolylineEndLineHandler(PolylineEndLineHandler).

Parameters:
handler - the handler to remove

removePolylineLineUpdatedHandler

public void removePolylineLineUpdatedHandler(PolylineLineUpdatedHandler handler)
Removes a single handler of this map previously added with addPolylineLineUpdatedHandler(PolylineLineUpdatedHandler).

Parameters:
handler - the handler to remove

removePolylineMouseOutHandler

public void removePolylineMouseOutHandler(PolylineMouseOutHandler handler)
Removes a single handler of this map previously added with addPolylineMouseOutHandler(PolylineMouseOutHandler).

Parameters:
handler - the handler to remove

removePolylineMouseOverHandler

public void removePolylineMouseOverHandler(PolylineMouseOverHandler handler)
Removes a single handler of this map previously added with addPolylineMouseOverHandler(PolylineMouseOverHandler).

Parameters:
handler - the handler to remove

removePolylineRemoveHandler

public void removePolylineRemoveHandler(PolylineRemoveHandler handler)
Removes a single handler of this map previously added with addPolylineRemoveHandler(PolylineRemoveHandler).

Parameters:
handler - the handler to remove

removePolylineVisibilityChangedHandler

public void removePolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler handler)
Removes a single handler of this map previously added with addPolylineVisibilityChangedHandler(PolylineVisibilityChangedHandler) .

Parameters:
handler - the handler to remove

setDrawingEnabled

public void setDrawingEnabled()
Allows a user to construct (or modify) a GPolyline object by clicking on additional points on the map. The Polyline must already be added to the map via MapWidget.addOverlay(Overlay), even if the polyline is initially unpopulated and contains no vertices. Each click adds an additional vertex to the polyline chain, and drawing may be terminated through either a double-click or clicking again on the last point added, at which point an PolylineEndLineHandler.PolylineEndLineEvent event will be triggered if the polyline was successfully completed; otherwise, a PolylineCancelLineHandler.PolylineCancelLineEvent event will be triggered, but the polyline will not be removed from the map. If modifying an existing Polyline , vertices are connected from either the starting or ending points of the existing polyline, specified in the optional {link PolyEditingOptions.setFromStart(boolean).


setDrawingEnabled

public void setDrawingEnabled(PolyEditingOptions opts)
Enable drawing as in setDrawingEnabled() but with control over the polyline drawing parameters.

Parameters:
opts - parameters for the polyline editing session.

setEditingEnabled

public void setEditingEnabled(boolean enabled)
Allows modification of an existing Polyline chain of points. When enabled, users may select and drag existing vertices. Unless a vertex limit less than current number of vertices is specified by PolyEditingOptions.setMaxVertices(int), "ghost" points will also be added at the midpoints of polyline sections, allowing users to interpolate new vertices by clicking and dragging these additional vertices. A PolylineLineUpdatedHandler.PolylineLineUpdatedEvent event will be triggered whenever vertex is added or moved. Note, you must add the polyline to the map before enabling editing.

Parameters:
enabled - true to turn on editing of this polyline.

setEditingEnabled

public void setEditingEnabled(PolyEditingOptions opts)
Enable editing as in setEditingEnabled(boolean), but with control over the polyline drawing parameters. Note, you must add the polyline to the map before enabling editing.

Parameters:
opts - parameters for the polyline editing session.

setStrokeStyle

public void setStrokeStyle(PolyStyleOptions style)
Changes the style of the polyline. The Polyline must already be added to the map via MapWidget.addOverlay(Overlay)

Parameters:
style - options for drawing the polyline.

setVisible

public void setVisible(boolean visible)
Show or hide the polyline.

Parameters:
visible - true to show the polyline.

supportsHide

public boolean supportsHide()
Returns true if this environment supports the setVisible(boolean) method.

Returns:
true if setVisible(false) is supported in the current environment.