org.gwtopenmaps.openlayers.client
Class Map

java.lang.Object
  extended by org.gwtopenmaps.openlayers.client.util.JSObjectWrapper
      extended by org.gwtopenmaps.openlayers.client.OpenLayersObjectWrapper
          extended by org.gwtopenmaps.openlayers.client.OpenLayersEObjectWrapper
              extended by org.gwtopenmaps.openlayers.client.Map

public class Map
extends OpenLayersEObjectWrapper

The Map class is the hub of OpenLayers. Instances of the Map class are "interactive maps embedded in a webpage". In GWT-OpenLayers the map is wrapped in a MapWidget which is a GWT Widget. GWT Widgets can receive events from the browser and can be added to GWT Panels.

    MapWidget mapWidget = new MapWidget("100%", "100%");
    Map map = mapWidget.getMap(); //instantiates map
    map.setControls(new LayerSwitcher());
 
Or
    MapOptions options = new MapOptions();
    options.setControls(new LayerSwitcher());
    MapWidget mapWidget = new MapWidget("100%", "100%", options);
    Map map = mapWidget.getMap(); //instantiates map
 

Adjusted from OL API docs: On their own maps do not provide much functionality. To extend a map it's necessary to add controls, see Control and layers, see Layer to the map.

Author:
Erdem Gunay, Amr Alam - Refractions Research, Aaron Novstrup - Stottler Henke Associates, Inc., Edwin Commandeur - Atlis Information Systems, Curtis Jensen - Integrity Applications Inc., Lukas Johansson

Nested Class Summary
static interface Map.BrowserMenuListener
           
 
Field Summary
 
Fields inherited from class org.gwtopenmaps.openlayers.client.OpenLayersEObjectWrapper
eventListeners
 
Constructor Summary
protected Map(JSObject e)
           
 
Method Summary
 void addControl(Control control)
           
 void addLayer(Layer layer)
           
 void addLayers(Layer[] layers)
           
 void addMapBaseLayerChangedListener(MapBaseLayerChangedListener listener)
           
 void addMapClickListener(MapClickListener listener)
           
 void addMapLayerAddedListener(MapLayerAddedListener listener)
           
 void addMapLayerChangedListener(MapLayerChangedListener listener)
           
 void addMapLayerRemovedListener(MapLayerRemovedListener listener)
           
 void addMapMarkerAddedListener(MapMarkerAddedListener listener)
           
 void addMapMarkerRemovedListener(MapMarkerRemovedListener listener)
           
 void addMapMoveEndListener(MapMoveEndListener listener)
           
 void addMapMoveListener(MapMoveListener listener)
           
 void addMapPopupClosedListener(MapPopupClosedListener listener)
           
 void addMapPopupOpenedListener(MapPopupOpenedListener listener)
           
 void addMapZoomListener(MapZoomListener listener)
           
 void addPopup(Popup popup)
           
 void addPopupExclusive(Popup popup)
          Closes all other popups first
 void destroy()
           
 void disableBrowserContextMenu(Map.BrowserMenuListener listener)
           
 boolean getAllOverlays()
           
 LonLat getCenter()
           
 Control getControlsByClass(String className)
           
 Bounds getExtent()
           
 Layer getLayer(String id)
          Get a layer based on the id assigned by OpenLayers.
 Layer getLayerByName(String name)
          This is not an OpenLayers native function.
 int getLayerIndex(Layer layer)
           
 Layer[] getLayers()
           
 Layer[] getLayersByName(String name)
           
 LonLat getLonLatFromPixel(Pixel pixel)
           
 Bounds getMaxExtent()
           
 double getMaxResolution()
           
 int getNumLayers()
           
 Pixel getPixelFromLonLat(LonLat lonlat)
           
 String getProjection()
           
 double getResolution()
           
 double getResolutionForZoom()
           
 double getScale()
           
 Size getSize()
           
 Size getTileSize()
           
 String getUnits()
          See also MapUnits.
 int getZoom()
          Returns current zoom level of map object.
 int getZoomForExtent(Bounds bounds, boolean closest)
           
static Map narrowToMap(JSObject object)
           
 void pan(int dx, int dy)
           
 void panTo(LonLat lonlat)
           
 void raiseLayer(Layer layer, int delta)
           
 void removeControl(Control control)
           
 void removeLayer(Layer layer)
           
 void removeLayer(Layer layer, boolean setNewBaseLayer)
           
 void removeMapClickListener(MapClickListener listener)
          Remove MapClickListener Defined on the Map
 void removeOverlayLayers()
          This is not an OpenLayers native function.
 void removePopup(Popup popup)
           
 void resetLayersZIndex()
          Method: resetLayersZIndex Reset each layer's z-index based on layer's array index
 void setBaseLayer(Layer newBaseLayer)
           
 void setCenter(LonLat lonlat)
           
 void setCenter(LonLat lonlat, int zoom)
           
 void setFractionalZoom(boolean fractionalZoom)
           Somehow this is not an API property in OL, but it seems it would make sense as an API property and it is well documented:
 void setLayerIndex(Layer layer, int index)
           
 void setLayerZIndex(Layer layer, int zIdx)
          Method: setLayerZIndex Parameters: layer - {} zIdx - {int}
 void setMaxExtent(Bounds extent)
           
 void setMinExtent(Bounds extent)
           
 void setOptions(MapOptions mapOptions)
           
 void setRestrictedExtent(Bounds extent)
           
 void updateSize()
          This function should be called by any external code which dynamically changes the size of the map div.
 void zoomTo(int zoomLevel)
           
 void zoomToExtent(Bounds bounds)
           
 void zoomToMaxExtent()
           
 void zoomToScale(float scale, boolean closest)
           
 
Methods inherited from class org.gwtopenmaps.openlayers.client.OpenLayersEObjectWrapper
getListeners, narrowToOpenLayersEObjectWrapper, removeListener
 
Methods inherited from class org.gwtopenmaps.openlayers.client.OpenLayersObjectWrapper
getClassName, getEvents, narrowToOpenLayersObjectWrapper
 
Methods inherited from class org.gwtopenmaps.openlayers.client.util.JSObjectWrapper
getJSObject, setJSObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map

protected Map(JSObject e)
Method Detail

narrowToMap

public static Map narrowToMap(JSObject object)

getCenter

public LonLat getCenter()
Returns:
LonLat - the coordinates of the center

setCenter

public void setCenter(LonLat lonlat)

setCenter

public void setCenter(LonLat lonlat,
                      int zoom)

addControl

public void addControl(Control control)

addLayer

public void addLayer(Layer layer)

addLayers

public void addLayers(Layer[] layers)

addPopup

public void addPopup(Popup popup)

addPopupExclusive

public void addPopupExclusive(Popup popup)
Closes all other popups first


removePopup

public void removePopup(Popup popup)

getNumLayers

public int getNumLayers()

getLayer

public Layer getLayer(String id)
Get a layer based on the id assigned by OpenLayers. A Layer can be asked for it's id. This id can be used to get at the layer within the application.

Parameters:
id - - String identifier assigned by OpenLayers
Returns:
Layer - the layer on the map or null if there is no layer with the given id

getLayers

public Layer[] getLayers()

getControlsByClass

public Control getControlsByClass(String className)

removeLayer

public void removeLayer(Layer layer)

removeLayer

public void removeLayer(Layer layer,
                        boolean setNewBaseLayer)
Parameters:
layer -
setNewBaseLayer - - {Boolean} default is true

removeControl

public void removeControl(Control control)

getLayerIndex

public int getLayerIndex(Layer layer)

setLayerIndex

public void setLayerIndex(Layer layer,
                          int index)

setLayerZIndex

public void setLayerZIndex(Layer layer,
                           int zIdx)
Method: setLayerZIndex Parameters: layer - {} zIdx - {int}


resetLayersZIndex

public void resetLayersZIndex()
Method: resetLayersZIndex Reset each layer's z-index based on layer's array index


getLayerByName

public Layer getLayerByName(String name)
This is not an OpenLayers native function. OpenLayers has getLayersByName that returns all layers matching the name.

Parameters:
name - - the name of a layer or part of it
Returns:
Layer - the first layer that matches the name (so, if there are more layers matching the name then only one is returned) or null if no layer matches

getLayersByName

public Layer[] getLayersByName(String name)
Parameters:
name - - the name of a layer or part of it
Returns:
Layer[] - all layers with a name that fully or partially matches the input name or null if no layer matches

removeOverlayLayers

public void removeOverlayLayers()
This is not an OpenLayers native function. Will remove all overlays from the this Map.


zoomToExtent

public void zoomToExtent(Bounds bounds)

getZoomForExtent

public int getZoomForExtent(Bounds bounds,
                            boolean closest)

getZoom

public int getZoom()
Returns current zoom level of map object.

Returns:
current zoom level

getLonLatFromPixel

public LonLat getLonLatFromPixel(Pixel pixel)

getPixelFromLonLat

public Pixel getPixelFromLonLat(LonLat lonlat)

getProjection

public String getProjection()

getUnits

public String getUnits()
See also MapUnits.

Returns:
String - the units used by the projection

getExtent

public Bounds getExtent()

getMaxExtent

public Bounds getMaxExtent()

getResolution

public double getResolution()

getScale

public double getScale()

raiseLayer

public void raiseLayer(Layer layer,
                       int delta)

zoomTo

public void zoomTo(int zoomLevel)

zoomToScale

public void zoomToScale(float scale,
                        boolean closest)

zoomToMaxExtent

public void zoomToMaxExtent()

setOptions

public void setOptions(MapOptions mapOptions)

panTo

public void panTo(LonLat lonlat)

pan

public void pan(int dx,
                int dy)

getTileSize

public Size getTileSize()

getSize

public Size getSize()

getMaxResolution

public double getMaxResolution()

getResolutionForZoom

public double getResolutionForZoom()

setFractionalZoom

public void setFractionalZoom(boolean fractionalZoom)

Somehow this is not an API property in OL, but it seems it would make sense as an API property and it is well documented:

For a base layer that supports it, allow the map resolution to be set to a value between one of the values in the resolutions array. Default is false. When fractionalZoom is set to true, it is possible to zoom to an arbitrary extent. This requires a base layer from a source that supports requests for arbitrary extents (i.e. not cached tiles on a regular lattice). This means that fractionalZoom will not work with commercial layers (Google, Yahoo, VE), layers using TileCache, or any other pre-cached data sources. If you are using fractionalZoom, then you should also use getResolutionForZoom instead of layer.resolutions[zoom] as the former works for non-integer zoom levels.


setMinExtent

public void setMinExtent(Bounds extent)

setMaxExtent

public void setMaxExtent(Bounds extent)

setRestrictedExtent

public void setRestrictedExtent(Bounds extent)

getAllOverlays

public boolean getAllOverlays()

setBaseLayer

public void setBaseLayer(Layer newBaseLayer)

updateSize

public void updateSize()
This function should be called by any external code which dynamically changes the size of the map div. It can also be called when experiencing the problem of the single small tile in the upper left corner (doesn't work in all situations thought)


destroy

public void destroy()

addMapBaseLayerChangedListener

public void addMapBaseLayerChangedListener(MapBaseLayerChangedListener listener)

addMapLayerAddedListener

public void addMapLayerAddedListener(MapLayerAddedListener listener)

addMapLayerChangedListener

public void addMapLayerChangedListener(MapLayerChangedListener listener)

addMapLayerRemovedListener

public void addMapLayerRemovedListener(MapLayerRemovedListener listener)

addMapMoveListener

public void addMapMoveListener(MapMoveListener listener)

addMapMoveEndListener

public void addMapMoveEndListener(MapMoveEndListener listener)

addMapZoomListener

public void addMapZoomListener(MapZoomListener listener)

addMapMarkerAddedListener

public void addMapMarkerAddedListener(MapMarkerAddedListener listener)

addMapMarkerRemovedListener

public void addMapMarkerRemovedListener(MapMarkerRemovedListener listener)

addMapPopupOpenedListener

public void addMapPopupOpenedListener(MapPopupOpenedListener listener)

addMapPopupClosedListener

public void addMapPopupClosedListener(MapPopupClosedListener listener)

addMapClickListener

public void addMapClickListener(MapClickListener listener)

removeMapClickListener

public void removeMapClickListener(MapClickListener listener)
Remove MapClickListener Defined on the Map

Parameters:
listener -

disableBrowserContextMenu

public void disableBrowserContextMenu(Map.BrowserMenuListener listener)


Copyright © 2011 sourceforge. All Rights Reserved.