com.esri.core.map
Class LayerModel

java.lang.Object
  extended by com.esri.core.map.LayerModel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DynamicLayerModel, TiledLayerModel

public abstract class LayerModel
extends Object
implements Serializable

The LayerMOdel class represents the base class for all layer models. You would work with one the higher level classes, for example, use TiledLayer for cached data; DynamicLayer for non-cached data;

In a Model-View-Controller architecture, this class represents the Model. It handles fetching map images, calculating map extent and so on.

See Also:
Serialized Form

Constructor Summary
LayerModel()
          Instantiates an empty LayerModel.
LayerModel(SpatialReference coordsys, Envelope full)
          Instantiates a LayerModel with the spatial coordinates system of the layer and full extent of the map.
 
Method Summary
 void centerAt(Point centerPt)
          Re-centers the map to the given point.
 Point getCenter()
          Gets the center point of the map.
 SpatialReference getDefaultSpatialReference()
          Returns the default spatial coordinates of the model, which is specified in the constructor.
 Envelope getExtent()
          Gets the current map extent.
 Envelope getFullExtent()
          Gets the full extent of the layer.
 double getResolution()
          Gets the current map resolutions based on the map extent and screen size settings.
 SpatialReference getSpatialReference()
          Gets the spatial coordinates used by the map view.
 void pan(float dx, float dy)
          Moves the layer by the given pixels.
 void resize(int newWidth, int newHeight)
          Resizes the map with the screen width and screen height.
 void setExtent(Envelope ext, int width, int height, SpatialReference sr)
          Sets the map extent.
 void setExtent(Point centerPt, double resolution, int width, int height, SpatialReference sr)
          Sets the extent using the center point and the resolution.
 void setFullExtent(Envelope fullExtent)
          Sets the full extent of the layer.
 void setResolution(double res)
          Sets the resolution of the layer.
 void setScreenSize(int w, int h)
          Sets the screen size.
 double zoom(float pdx, float pdy, double to)
          Zooms the map to the given resolution at the pivot screen point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayerModel

public LayerModel()
Instantiates an empty LayerModel.


LayerModel

public LayerModel(SpatialReference coordsys,
                  Envelope full)
Instantiates a LayerModel with the spatial coordinates system of the layer and full extent of the map.

Parameters:
coordsys - the default spatial reference of the layer.
full - the full extent of the layer.
Method Detail

setExtent

public void setExtent(Envelope ext,
                      int width,
                      int height,
                      SpatialReference sr)
Sets the map extent. The extent will be adjusted based on the aspect ratio of the given screen width and height.

The spatial coordinates of the center point will be used as the layer's spatial reference, and the map image will be returned in this coordinate system.

Parameters:
ext - the new map extent.
width - the screen width in pixels
height - the screen height in pixels

setExtent

public void setExtent(Point centerPt,
                      double resolution,
                      int width,
                      int height,
                      SpatialReference sr)
Sets the extent using the center point and the resolution. The spatial reference of the center point will be used as the layer's spatial reference, and the map image will be returned in this coordinate system.

Parameters:
centerPt - the map center;
width - map width in pixels
height - map height in pixels
sr - the coordinates of the map extent

resize

public void resize(int newWidth,
                   int newHeight)
Resizes the map with the screen width and screen height. The current map center will be used as the pivot point when resizing.

Parameters:
newWidth - the screen width in pixels.
newHeight - the screen height in pixels.

centerAt

public void centerAt(Point centerPt)
Re-centers the map to the given point. The point must be given in the current map coordinates.

Parameters:
centerPt - the new map center;

getExtent

public Envelope getExtent()
Gets the current map extent.


getCenter

public Point getCenter()
Gets the center point of the map.


pan

public void pan(float dx,
                float dy)
Moves the layer by the given pixels.

Parameters:
dx - the offset x coordinate in pixels.
dy - the offset y coordinate in pixels.

zoom

public double zoom(float pdx,
                   float pdy,
                   double to)
Zooms the map to the given resolution at the pivot screen point. The pivot point is defined as a offset of the screen center point.

Parameters:
to - the new resolution.
pdx - the x coordinate of the center offset.
pdy - the y coordinate of the center offset.

getDefaultSpatialReference

public SpatialReference getDefaultSpatialReference()
Returns the default spatial coordinates of the model, which is specified in the constructor.


getSpatialReference

public SpatialReference getSpatialReference()
Gets the spatial coordinates used by the map view. This is what the map view is using to draw the map.


setScreenSize

public void setScreenSize(int w,
                          int h)
Sets the screen size.

Parameters:
w - the width in pixels.
h - the height in pixels.

setResolution

public void setResolution(double res)
Sets the resolution of the layer.

Parameters:
res - the new resolution.

getResolution

public double getResolution()
Gets the current map resolutions based on the map extent and screen size settings.


setFullExtent

public void setFullExtent(Envelope fullExtent)
Sets the full extent of the layer.

Parameters:
fullExtent - the new extent.

getFullExtent

public Envelope getFullExtent()
Gets the full extent of the layer.



Copyright © 2010. All Rights Reserved.