com.google.gwt.maps.client.geom
Class MercatorProjection

java.lang.Object
  extended by com.google.gwt.maps.client.geom.Projection
      extended by com.google.gwt.maps.client.geom.MercatorProjection

public final class MercatorProjection
extends Projection

An implementation of the Projection interface for the Mercator projection is used by all predefined map types. A Mercator projection is one way to map a sphere onto a two dimensional surface and is typically used for world maps. A Mercator projection shows all lines of longitude as parallel vertical lines rather than intersecting line, therefore, distances become distorted near the poles. A Mercator map projection not only allows a rectangular map to be drawn. but also easily allows tiles to be aligned for a continuous image.


Field Summary
 
Fields inherited from class com.google.gwt.maps.client.geom.Projection
jsoPeer
 
Constructor Summary
  MercatorProjection(int numZoomLevels)
          Constructs a Mercator projection for the given number of zoom levels.
protected MercatorProjection(com.google.gwt.core.client.JavaScriptObject jsoPeer)
          Wrap an existing GMercatorProjection object.
 
Method Summary
 Point fromLatLngToPixel(LatLng latlng, int zoomLevel)
          Returns the map coordinates in pixels for the point at the given geographical coordinates, and the given zoom level.
 LatLng fromPixelToLatLng(Point point, int zoomLevel, boolean unbound)
          Returns the geographical coordinates for the point at the given map coordinates in pixels, and the given zoom level.
 double getWrapWidth(int zoomLevel)
          Mercator projection is periodic in longitude direction, therefore this returns the width of the map of the entire Earth in pixels at the given zoom level.
 boolean tileCheckRange(TileIndex index, int zoomLevel, int tileSize)
          Indicates to the map if the tile index is in a valid range for the map type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MercatorProjection

public MercatorProjection(int numZoomLevels)
Constructs a Mercator projection for the given number of zoom levels.

Parameters:
numZoomLevels - the number of zoom levels to support.

MercatorProjection

protected MercatorProjection(com.google.gwt.core.client.JavaScriptObject jsoPeer)
Wrap an existing GMercatorProjection object.

Parameters:
jsoPeer - the existing JavaScript object to wrap.
Method Detail

fromLatLngToPixel

public Point fromLatLngToPixel(LatLng latlng,
                               int zoomLevel)
Description copied from class: Projection
Returns the map coordinates in pixels for the point at the given geographical coordinates, and the given zoom level.

Specified by:
fromLatLngToPixel in class Projection
Parameters:
latlng - map coordinates to translate.
zoomLevel - zoom level to translate.
Returns:
the map coordinates in pixels for the point at the given geographical coordinates, and the given zoom level.

fromPixelToLatLng

public LatLng fromPixelToLatLng(Point point,
                                int zoomLevel,
                                boolean unbound)
Description copied from class: Projection
Returns the geographical coordinates for the point at the given map coordinates in pixels, and the given zoom level. Flag unbounded causes the geographical longitude coordinate not to wrap when beyond the -180 or 180 degrees meridian.

Specified by:
fromPixelToLatLng in class Projection
Parameters:
point - the point at the given map coordinates in pixels to translate.
zoomLevel - zoom level to translate.
unbound - if true, causes the geographical longitude coordinate not to wrap when beyond the -180 or 180 degrees meridian.
Returns:
the geographical coordinates for the point at the given map coordinates.

getWrapWidth

public double getWrapWidth(int zoomLevel)
Mercator projection is periodic in longitude direction, therefore this returns the width of the map of the entire Earth in pixels at the given zoom level.

Specified by:
getWrapWidth in class Projection
Parameters:
zoomLevel - the zoom level to use.
Returns:
the periodicity in x-direction, i.e. the number of pixels after which the map repeats itself). Specify Double.POSITIVE_INFINITY to indicate that the map does not repeat.
See Also:
Projection.getWrapWidth(int)

tileCheckRange

public boolean tileCheckRange(TileIndex index,
                              int zoomLevel,
                              int tileSize)
Description copied from class: Projection
Indicates to the map if the tile index is in a valid range for the map type. Otherwise the map will display an empty tile.

Specified by:
tileCheckRange in class Projection
Parameters:
index - the tile index to check. The coordinates may be modified to point to another instance of the same tile in the case that the map contains more than one copy of the earth, and hence the same tile at different tile coordinates.
zoomLevel - the zoom level to check
Returns:
true if the tile index is in a valid range for the map type.