|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esri.adf.web.data.WebMap
public class WebMap
The WebMap is an attribute of WebContext (WebMap)context.getAttribute("map");
It defines properties of
the map including extent, size, image DPI etc.
A WebMap object generally is defined in the faces-config.xml file of web applications. The following shows how it can be configured as an attribute of the WebContext.
<managed-bean> <managed-bean-name>mapContext</managed-bean-name> <managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>attributes</property-name> <map-entries> <map-entry> <key>map</key> <value>#{webappMap}</value> </map-entry> .....The object gets instantiated when WebContext initializes. The default settings of a WebMap are:
<managed-bean> <managed-bean-name>webappMap</managed-bean-name> <managed-bean-class>com.esri.adf.web.data.WebMap</managed-bean-class> <managed-bean-scope>none</managed-bean-scope> <managed-property> <property-name>imageFormat</property-name> <value>PNG</value> </managed-property> </managed-bean>
A WebMap can have a set of functionalities which can be either of type MapFunctionality
or
TileFunctionality
. When the resource is cached, it can have a TileFunctionality, otherwise it is a dynamic
resource and have a MapFunctionality.
A set of pre-defined ADF web controls (e.g. MapControl
) can work with WebMap
to provide extend functions on a map such as map navigation, zoom etc.
The MapControl works with WebMap to render maps. The MapRenderer
class
renders the control to the appropriate markup, and the MapTag
class exposes the
control as a JSP custom tag named map.
For users who don't use web controls to manipulate maps, they can use WebMap directly. Following code snippet shows
how to create a set of map images with ExportFunctionality
.
//get WebMap from WebContext WebMap webMap = webContext.getWebMap(); //specify output size and format etc. ExportProperties exportProperties = new ExportProperties(); exportProperties.setImageFormat(webMap.getImageFormat()); exportProperties.setDpi(screenDPI); // constant; exportProperties.setWidth(500); exportProperties.setHeight(500); exportProperties.setExtent(webMap.getCurrentExtent()); ArrayList<InputStream> imageStreams = new ArrayList<InputStream>(); Collection<MapFunctionality> mapFuncs = webMap.getMapFunctionalities(); InputStream is = null; //Create images for each MapFunctionality for (MapFunctionality mf : mapFuncs) { if (mf.isDisabled()) { continue; } if (mf instanceof ExportFunctionality) { ExportFunctionality exf = (ExportFunctionality) mf; //create the image byte array. is = exf.export(exportProperties); if (is != null) { imageStreams.add(is); } } }
Similarly, user can change layer's visibility or other map definitions with MapFunctionality
.
MapFunctionality
,
TileFunctionality
,
Serialized FormField Summary | |
---|---|
protected WebContext |
context
The WebContext associated with the map. |
protected WebExtent |
currExtent
The current map's boundary. |
static int |
DEFAULT_DPI
Default DPI of the map, 96 by default. |
static int |
DEFAULT_HEIGHT
Default height of the map, 400 by default. |
static String |
DEFAULT_IMAGE_FORMAT
Default image format of the map is "png" |
static int |
DEFAULT_WIDTH
Default width of the map, 400 by default. |
protected int |
dpi
The DPI of the map. |
protected WebExtent |
fullExtent
The map's full boundary that all of the map's feature layers fall within its bounds. |
protected boolean |
fuseGraphics
Set to true to create both graphics elements and base map in one image. |
protected int |
height
The height of the map. |
protected byte[] |
imageBytes
The byte array of the map image. |
protected Map<MapFunctionality,byte[]> |
imageDataBytes
Deprecated. As of ArcGIS Java Server 10.0, no replacement |
protected String |
imageFormat
The image format of the map. |
protected boolean |
init
Indicates whether the map is initialized, "false" by default. |
protected WebExtent |
initExtent
The map's boundary when instantiated. |
protected ArrayList<MapFunctionality> |
mapFuncs
Defines functionality list of the map. |
protected boolean |
useMIMEData
Indicates whether MIME data is used, "true" by default. |
protected boolean |
visible
The visibility of the map, "true" by default. |
protected int |
width
The width of the map. |
Constructor Summary | |
---|---|
WebMap()
|
Method Summary | |
---|---|
void |
centerAt(WebPoint mapPoint,
double zoomFactor)
Recalculates the map extent by the given center and zoom factor. |
byte[] |
createCustomImage(WebSymbol symbol)
Creates an image used by Map Control if all the resources associated with WebContext are unavailable. |
void |
destroy()
The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in
this method. |
void |
exportMapImage()
Creates a map image based on current map settings, and it may return null. |
Map<GISResource,GISFunctionality> |
getAvailableFunctionalities()
Returns the available web map functionalities for all the resources. |
List<TileFunctionality> |
getAvailableTileFunctionalities()
Returns all TileFunctionality associated with the map. |
TileFunctionality |
getAvailableTileFunctionality()
Returns the first available TileFunctionality associated with the map. |
Map<TileFunctionality,ContainingTile> |
getContainingTiles()
Gets the valid zoom levels and their associated functionality. |
WebExtent |
getCurrentExtent()
Gets the new map extent. |
int |
getCurrentTileLevel()
Gets the tile zoom lever of the current map. |
int |
getDpi()
Returns the DPI of the map. |
WebExtent |
getFullExtent()
Gets the full extend of the map. |
double |
getGraphicsTransparency()
Returns the transparency value for the custom graphics. |
int |
getHeight()
Returns the height of the map. |
byte[] |
getImageBytes()
Similar to getImageUrl() , it returns byte array. |
Map<MapFunctionality,byte[]> |
getImageDataBytes()
Gets the map image byte array for each resources. |
String |
getImageFormat()
Returns the format of the map image. |
String |
getImageUrl()
Returns the fused map image URL if all the resources of the map are dynamic. |
Map<MapFunctionality,String> |
getImageURLs()
Gets the map URLs for each resources. |
WebExtent |
getInitExtent()
Gets the initialize extent. |
Collection<MapFunctionality> |
getMapFunctionalities()
Returns all the functionality associated with this map which can be either of type MapFunctionality or
TileFunctionality . |
double |
getMapScale()
Gets the map scale from associated functionality. |
double |
getRotation()
Returns the number of degrees by which the map will be rotated. |
int |
getTileLevelCount()
Gets the number of levels that the map will be tiled at . |
WebContext |
getWebContext()
Return the WebContext associated with this WebMap. |
int |
getWidth()
Returns the width of the map in pixels, by default the map size is 400 * 400. |
void |
init(WebContext webcontext)
Initializes the WebMap by associating itself with this context. |
boolean |
isBrowserBlending()
Returns whether the individual map images from different resources should be blended on the browser or fused into a single map image on the web server. |
boolean |
isCacheFeaturesOnBrowser()
Specifies whether the GraphicFeatures used for displaying maptips should be cached on the browser. |
boolean |
isEnableInfoWindow()
Returns an indicator whether the Map Control is configured to send an AJAX request for displaying Info Window. |
boolean |
isFuseGraphics()
Returns an indicator whether the control add custom graphics or not. |
boolean |
isInit()
Returns an indicator of whether WebMap is initialized. |
boolean |
isLastEnabledMapFunctionality(MapFunctionality mapFunc)
Returns true if the functionality the last one in the stock and which is enabled. |
boolean |
isUseMIMEData()
Returns whether the map image will be fetched as MIME data from the GIS service. |
boolean |
isVisible()
Returns an indicator whether the map is visible. |
boolean |
isWebMapAvailable()
Returns true if this WebMap is in a valid state and available to the clients. |
boolean |
isZoomBeyondCache()
By default, when a application contains both cached and dynamic services, it displays data only at cached services’ scale-levels. |
void |
setBrowserBlending(boolean browserBlending)
Specifies whether the individual map images from different resources should be blended on the browser or fused into a single map image on the web server. |
void |
setCacheFeaturesOnBrowser(boolean cacheFeatures)
Specifies whether the GraphicFeatures used for displaying maptips should be cached on the browser. |
void |
setCurrentExtent(WebExtent webextent)
Changes the current extent to the given one. |
void |
setDpi(int dpi)
Sets the DPI of the map. |
void |
setEnableInfoWindow(boolean enableInfoWindow)
Setting this property to true will enable the Info Window AJAX request on Map Control. |
void |
setFullExtent(WebExtent fullExtent)
Sets the full extent to override the calculated extent. |
void |
setFuseGraphics(boolean fuseGraphics)
Sets whether the control fuse the custom graphics or not. |
void |
setGraphicsTransparency(double transparency)
Sets the transparency for the custom graphics. |
void |
setHeight(int height)
Sets the height of the map. |
void |
setImageFormat(String imageFormat)
Sets the format of the map image. |
void |
setInit(boolean init)
Sets an indicator whether to initialize WebMap. |
void |
setInitExtent(WebExtent initExtent)
The extent to initialize the map. |
void |
setMapScale(double scale)
Sets the map scale. |
void |
setRotation(double rotation)
Sets the number of degrees by which the map will be rotated. |
void |
setUseMIMEData(boolean useMIMEData)
Sets whether the map image should be requested as MIME data from the GIS service. |
void |
setVisible(boolean visible)
Sets the visibility of the map. |
void |
setWidth(int width)
Sets the width of the map in pixels, by default the map size is 400 * 400. |
void |
setZoomBeyondCache(boolean zoomBeyondCache)
Sets the value of the property "zoomBeyondCache". |
void |
update(WebContext webcontext,
Object arg)
This method is called by the WebContext on its registered WebContextObserver s when users call the
refresh() methods on the context. |
void |
zoomToTileLevel(int level)
Zooms to the given tile level. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
public static final int DEFAULT_DPI
public static final String DEFAULT_IMAGE_FORMAT
protected WebContext context
WebContext
associated with the map.
protected int height
DEFAULT_HEIGHT
.
protected int width
DEFAULT_WIDTH
.
protected boolean visible
protected boolean useMIMEData
protected boolean init
protected int dpi
DEFAULT_DPI
.
protected String imageFormat
protected WebExtent fullExtent
protected WebExtent initExtent
protected WebExtent currExtent
protected boolean fuseGraphics
setFuseGraphics(boolean)
protected ArrayList<MapFunctionality> mapFuncs
MapFunctionality
or TileFunctionality
. When the resource is cached, it can have a
TileFunctionality, otherwise it is a dynamic resource and have a MapFunctionality.
protected byte[] imageBytes
@Deprecated protected Map<MapFunctionality,byte[]> imageDataBytes
Constructor Detail |
---|
public WebMap()
Method Detail |
---|
public void init(WebContext webcontext)
init
in interface WebContextInitialize
webcontext
- WebContextWebContext.init(WebContext)
,
WebContext.addResource(String, GISResource, int)
,
WebContext.removeResource(GISResource)
public void destroy()
WebContextInitialize
The cleaup chores (such as releasing held resources) of attributes of a WebContext
should be performed in
this method.
Typically this method is called by the WebContext
when the context itself is destroyed.
The WebContext
attribute is unusable after this method has been called.
destroy
in interface WebContextInitialize
WebContext.destroy()
public void update(WebContext webcontext, Object arg)
WebContextObserver
This method is called by the WebContext
on its registered WebContextObserver
s when users call the
refresh()
methods on the context.
To setup an object to be updated by the context, one needs to use the
WebContext.addObserver(WebContextObserver)
to register itself with the context. All
context attributes are wired up to the WebContext
. When users change state on any of
the attributes and need to intimate other attributes of the context to react to the change they call either the
WebContext.refresh()
or WebContext.refresh(Object)
methods. The context in turns calls the WebContextObserver.update(WebContext, Object)
methods on all its registered
observers.
update
in interface WebContextObserver
webcontext
- the WebContext
that has been refreshedarg
- the argument passed to the WebContext
's refresh(arg)
methodWebContext.refresh(Object)
,
WebContext.addObserver(WebContextObserver)
,
WebContext.removeObserver(WebContextObserver)
public TileFunctionality getAvailableTileFunctionality()
null
.TileFunctionality
public List<TileFunctionality> getAvailableTileFunctionalities()
List
TileFunctionality
public int getTileLevelCount()
TileFunctionality
public int getCurrentTileLevel()
getTileLevelCount()
, it means the map is zoom beyond the cache levels.
isZoomBeyondCache()
public void zoomToTileLevel(int level)
TileFunctionality
public Map<TileFunctionality,ContainingTile> getContainingTiles()
zoomBeyondCache == false
. This methods returns
qualified TileFunctionality and pre-defined zoom levels.
isZoomBeyondCache()
,
TileFunctionality
public Map<GISResource,GISFunctionality> getAvailableFunctionalities()
MapFunctionality
or TileFunctionality
.
GISResource
, GISFunctionality
>public Map<MapFunctionality,String> getImageURLs()
public Map<MapFunctionality,byte[]> getImageDataBytes()
getImageURLs()
, this method returns byte array
instead of URLs.
public void exportMapImage()
public String getImageUrl()
public byte[] getImageBytes()
getImageUrl()
, it returns byte array.
public Collection<MapFunctionality> getMapFunctionalities()
MapFunctionality
or
TileFunctionality
. When the resource is cached, it can have a TileFunctionality, otherwise it is a dynamic
resource and have a MapFunctionality.
public WebExtent getFullExtent()
public void setFullExtent(WebExtent fullExtent)
fullExtent
- public WebExtent getInitExtent()
public void setInitExtent(WebExtent initExtent)
initExtent
- public WebExtent getCurrentExtent()
public void setCurrentExtent(WebExtent webextent)
webextent
- the new extent.public void centerAt(WebPoint mapPoint, double zoomFactor)
mapPoint
- the map center in real world spatial reference.zoomFactor
- Factor must be greater than zero. WebExtent is enlarged horizontally and vertically by deltaw and
deltah respectively, where deltaw = this.getWidth() * (1 - factor) / 2; deltah =
this.getHeight() * (1 - factor) / 2;
public double getMapScale()
public void setMapScale(double scale)
getMapScale()
will return user's setting instead of use map scale on
functionality; however it won't change map's extent or zoom level.
scale
- the use defined scale.public boolean isLastEnabledMapFunctionality(MapFunctionality mapFunc)
mapFunc
- the object to check.
public WebContext getWebContext()
WebContext
associated with this WebMap.
WebContext
- the WebContextpublic void setHeight(int height)
height
- the heightpublic int getHeight()
public void setWidth(int width)
width
- the widthpublic int getWidth()
public void setVisible(boolean visible)
visible
- if true, visiblepublic boolean isVisible()
public void setInit(boolean init)
init
- if true, initializepublic boolean isInit()
public void setDpi(int dpi)
dpi
- the DPIpublic int getDpi()
public void setImageFormat(String imageFormat)
The formats supported are png, png24, dib, emf, bmp, jpeg, jpg, gif
imageFormat
- a valid image format stringpublic String getImageFormat()
The formats supported are png, png24, dib, emf, bmp, jpeg, jpg, gif
String
- the image formatpublic void setUseMIMEData(boolean useMIMEData)
useMIMEData
- if true, map image is returned as MIME data.public boolean isUseMIMEData()
public void setFuseGraphics(boolean fuseGraphics)
fuseGraphics
- if true, the custom graphics are addedpublic boolean isFuseGraphics()
public void setBrowserBlending(boolean browserBlending)
isFuseGraphics()
is not consulted and the graphics are overlayed
on top of the map images in the browser.
browserBlending
- if true, the browser blending is turned onpublic boolean isBrowserBlending()
public void setEnableInfoWindow(boolean enableInfoWindow)
enableInfoWindow
- if true, the Map Control enable the AJAX request for Info WindowInfoWindowPhaseListener
,
InfoWindowPhaseListener.REQUEST_PARAM
public boolean isEnableInfoWindow()
InfoWindowPhaseListener
,
InfoWindowPhaseListener.REQUEST_PARAM
public void setGraphicsTransparency(double transparency)
transparency
- the custom graphics transparencypublic double getGraphicsTransparency()
public void setRotation(double rotation)
rotation
- the number of degreespublic double getRotation()
public boolean isWebMapAvailable()
Returns true if this WebMap
is in a valid state and available to the clients.
A WebMap
is not in a valid state if there are not map functionalities associated with it. This typically
happens when all map resources fail to initialize rendering the WebMap
unusable.
WebMap
is in a valid state and available to the clientspublic byte[] createCustomImage(WebSymbol symbol)
WebContext
are unavailable.
public boolean isZoomBeyondCache()
zoomBeyondCache == true
, the map not only can be
rendered at those 3 levels, but also can be zoomed out beyond 1:16 and be zoomed in beyond 1:64 if there is a
available dynamic service at the given scale.
public void setZoomBeyondCache(boolean zoomBeyondCache)
zoomBeyondCache
- The zoomBeyondCache to set.setZoomBeyondCache(boolean)
public void setCacheFeaturesOnBrowser(boolean cacheFeatures)
cacheFeatures
- if true, the maptips features are cached on the browserpublic boolean isCacheFeaturesOnBrowser()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |