|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object android.view.View android.view.ViewGroup com.esri.android.map.MapView
public class MapView
The MapView is the main mapping component of the ArcGIS API for Android. It represents an Android View that will display a map with a set of service layers. The MapView can be navigated using a device's touch screen. By default the MapView will respond to the following gestures:
Notice that the MapView inherits directly from Android's ViewGroup. Therefore, the MapView class inherits all the
methods and properties from the ViewGroup and is very similar to working with other Android views. To make the
MapView functional, it must have at least one Layer
as its child. In general, the MapView is the parent of
all Layer
children.
The following are examples of how you might work with the MapView. The code will add a map service from ArcGIS Online
using map services that have been cached. When working with cached map services the
ArcGISTiledMapServiceLayer
class must be used, which is a type of Layer
. There are two approaches you
can take when initializing your MapView, either through a layout's XML or through Java source code. This example code
shows you how to connect to ArcGIS Online, but you can easily update the code to point to your own ArcGIS Server REST
end points.
XML usage:
<!-- MapView that will fill your device screen with the "Washington, DC" hosted on ArcGIS.com. -->
<com.esri.android.map.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
url="http://www.arcgis.com/home/webmap/viewer.html?webmap=e229d715f7ca4fa980308549fb288165"/>
Java usage:
//ArcGISTiledMapServiceLayer class is used to define the Layer that is added to the
//MapView object.
MapView mv = new MapView(this);
mv.addLayer(new ArcGISTiledMapServiceLayer(
"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
setContentView(mv);
The first layer that is added to the MapView using either approach presented previously will defines its initial extent, resolution, and spatial reference for the entire map. To change any of these attributes, use the corresponding setter methods; otherwise the MapView will maintain these initial values during the lifetime of the object.
To instantiate a MapView from a URL of a WebMap, you can do it either through the layerout xml or through Java code. When the WebMap has Bing map layers, you need to provide application ID to access the Bing map.
XML usage:
<!-- MapView that will fill your device screen with the "mspservice" hosted on ArcGIS Online. -->
<com.esri.android.map.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
appId="the id...."
url="http://webmap/mapservice with a Bing map layer/"/>
Java usage:
MapView mv = new MapView(this,"http://webmap/mapservice with a Bing map layer", null, null, "your appId here");
setContentView(mv);
When instantiating the MapView, as done in the Java usage example shown previously, you cannot assume that the object is initialized immediately due to the normal life cycle of an Activity. For instance, when you initialize the MapView and attempt to get the resolution immediately after you call the constructor, nothing will happen because the MapView will not have completely initialize. This will happen if you attempt to call the following methods of the MapView immediately after constructing your object:
The proper way to write code to perform actions after the map is initialized do the following:
public class MapViewCenterAt extends Activity {
MapView map;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapviewcenterat);
map = (MapView) findViewById(R.id.map);
// the right way to get map resolution
map.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
public void onStatusChanged(View source, STATUS status) {
if (OnStatusChangedListener.STATUS.INITIALIZED == status && source == map) {
Log.d("Test", "resolution:" + map.getResolution());
}
}
});
}
When initialize a MapView, the OnStatusChangedListener notifies you the status changes from both the MapView and
Layers. You need to use the source of the event to distinguish them. When the initialization is failed, you can use
the OnStatusChangedListener.STATUS.getError()
to get the error details.
Also, you can check the map view status using this method: isLoaded()
OnStatusChangedListener
Nested Class Summary |
---|
Nested classes/interfaces inherited from class android.view.ViewGroup |
---|
android.view.ViewGroup.LayoutParams, android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener |
Nested classes/interfaces inherited from class android.view.View |
---|
android.view.View.BaseSavedState, android.view.View.MeasureSpec, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnFocusChangeListener, android.view.View.OnKeyListener, android.view.View.OnLongClickListener, android.view.View.OnTouchListener |
Field Summary |
---|
Fields inherited from class android.view.ViewGroup |
---|
FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE |
Fields inherited from class android.view.View |
---|
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SOUND_EFFECTS_ENABLED, VISIBLE |
Constructor Summary | |
---|---|
MapView(android.content.Context context)
The constructor is used if you are instantiating the MapView using Java code (see the class description for an example of this usage). |
|
MapView(android.content.Context context,
android.util.AttributeSet attrs)
This constructor is called when the MapView object is being inflated from XML. |
|
MapView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle)
Inflate the MapView object from XML and apply a class-specific base style. |
|
MapView(android.content.Context context,
SpatialReference spatialreference,
Envelope extent)
The constructor is used if you are instantiating the MapView using Java code (see the class description for an example of this usage). |
|
MapView(android.content.Context context,
String url,
String user,
String passwd)
The constructor is used if you are instantiating the MapView using the URL of a WebMap. |
|
MapView(android.content.Context context,
String url,
String user,
String passwd,
String bingMapsAppId)
The constructor is used if you are instantiating the MapView using the URL of a WebMap. |
|
MapView(android.content.Context context,
String url,
String user,
String passwd,
String bingMapsAppId,
OnMapEventListener listener)
The constructor is used if you are instantiating the MapView using the URL of a WebMap. |
|
MapView(android.content.Context context,
WebMap webmap,
String bingMapsAppId,
OnMapEventListener listener)
The constructor is used if you are instantiating the MapView using a WebMap. |
Method Summary | |
---|---|
int |
addLayer(Layer layer)
Adds the child Layer. |
int |
addLayer(Layer layer,
int index)
Adds the child Layer at the given index. |
void |
addLayers(Layer[] layerArray)
Adds the Layer array. |
void |
centerAt(Point centerPt,
boolean animated)
If the MapView is initialized, centers the map at the given point. |
android.view.ViewGroup.LayoutParams |
generateLayoutParams(android.util.AttributeSet attrs)
|
Callout |
getCallout()
Returns a callout window |
Point |
getCenter()
Returns the center of the MapView as an ArcGIS geometry Point. |
android.graphics.Bitmap |
getDrawingMapCache(float x,
float y,
int w,
int h)
Creates a drawing cache of the map in the given extent. |
Polygon |
getExtent()
Returns a polygon comprising of four corners of map in map coordinates. |
Grid |
getGrid()
Returns the Grid instance of the map which allows for the type and visibility of the grid to be controlled. |
Layer |
getLayer(int index)
Gets a layer at the given index. |
Layer |
getLayerByURL(String url)
Gets a layer by its service URL. |
Layer[] |
getLayers()
Returns all child Layers that are added to the MapView. |
LocationService |
getLocationService()
Returns the unique instance of the location service |
Envelope |
getMapBoundaryExtent()
Returns the boundary extent of the map. |
double |
getMaxResolution()
Gets the maximum resolution of the MapView. |
double |
getMinResolution()
Gets the minimum resolution of the map. |
OnLongPressListener |
getOnLongPressListener()
Gets the OnLongPressListener of the MapView. |
OnPanListener |
getOnPanListener()
Gets the OnPanListener of the MapView. |
OnPinchListener |
getOnPinchListener()
Gets the OnPinchListener of the MapView. |
OnSingleTapListener |
getOnSingleTapListener()
Gets the onSingleTapListener of the MapView. |
OnStatusChangedListener |
getOnStatusChangedListener()
Gets the OnStatusChangedListener of the MapView. |
OnZoomListener |
getOnZoomListener()
Gets the OnZoomListener of the MapView. |
double |
getResolution()
Returns the resolution of the MapView. |
double |
getRotationAngle()
Returns the current map rotation angle(in degree). |
double |
getScale()
A convenience method for obtaining the current map scale . |
SpatialReference |
getSpatialReference()
Returns the spatial coordinate system being used by the MapView. |
boolean |
isAllowRotationByPinch()
Returns true if the rotation by pinch is allowed. |
boolean |
isLoaded()
Returns true if the MapView is initialized. |
boolean |
isRecycled()
Returns true if the MapView has been recycled. |
void |
onChildViewAdded(android.view.View parent,
android.view.View child)
|
void |
onChildViewRemoved(android.view.View parent,
android.view.View child)
|
void |
pause()
Pauses the map. |
void |
recycle()
Releases the resources referenced by the MapView so that they can be recycled. |
void |
removeAll()
Removes all child layers from the map. |
void |
removeLayer(int index)
Removes a child layer at the given index. |
void |
removeLayer(Layer layer)
Removes the child Layer from the parent MapView. |
void |
restoreState(String state)
Restores the center and resolution of the MapView from the given String that is typically setup in an Activity's onPause() method (see MapView's retainMapInfo() method for details). |
String |
retainState()
The MapView's state should be persisted using a String object. |
void |
setAllowRotationByPinch(boolean allowRotationByPinch)
Allows/disallow pinch to rotate |
void |
setEsriLogoVisible(boolean visible)
Turns on or off the ESRI logo. |
void |
setExtent(Geometry geometry)
This method will zoom map into the given geometry and use its bound as current map extent. |
void |
setExtent(Geometry geometry,
int padding)
Zooms into the given geometry so that geometry fits the bounds of the map. |
void |
setMapBackground(int bkColor,
int gridColor,
float gridSize,
float gridLineSize)
Sets the map background with color and grid. |
void |
setMaxResolution(double maxResolution)
Sets the maximum resolution of the MapView. |
void |
setMinResolution(double minResolution)
Sets the minimum resolution of the map. |
void |
setOnLongPressListener(OnLongPressListener onLongPressListener)
Sets the OnLongPressListener of the MapView. |
void |
setOnPanListener(OnPanListener onPanListener)
Sets the OnPanListener of the MapView. |
void |
setOnPinchListener(OnPinchListener onPinchListener)
Sets the onPinchListener of the MapView. |
void |
setOnSingleTapListener(OnSingleTapListener onSingleTapListener)
Sets the onSingleTapListener of the MapView. |
void |
setOnStatusChangedListener(OnStatusChangedListener onStatusChangedListener)
Sets the OnStatusChangedListener of the MapView. |
void |
setOnZoomListener(OnZoomListener onZoomListener)
Sets the OnZoomListener of the MapView. |
void |
setResolution(double res)
Sets the resolution of the MapView. |
void |
setRotationAngle(double degree)
The method will rotate the map in the given angle(in degree) at a screen point(x and y in pixel); if the given angle number is positive, map will rotate anti-clockwise. |
void |
setRotationAngle(double degree,
float pivotX,
float pivotY)
The method will rotate the map in the given angle(in degree) at a screen point(x and y in pixel); if the given angle number is positive, map will rotate anti-clockwise. |
void |
setScale(double scale)
A convenience method for setting the map scale . |
Point |
toMapPoint(float screenx,
float screeny)
A convenience method that will convert a device's screen coordinates to an ArcGIS geometry Point that has the same spatial coordinate system as the MapView's. |
Point |
toMapPoint(Point src)
A convenience method that will convert a device's screen coordinates into an ArcGIS geometry Point that has the same spatial coordinate system as the MapView's. |
Point |
toScreenPoint(Point src)
A convenience method that will convert an ArcGIS geometry Point from the MapView's spatial coordinate system into the device's screen coordinates. |
void |
unpause()
Unpauses the map. |
void |
zoomin()
Zooms in one level from current map resolution. |
void |
zoomout()
Zooms out one level from current map resolution. |
void |
zoomTo(Point centerPt,
float factor)
If the MapView is initialized, zooms the map by a factor to the given center point. |
void |
zoomToResolution(Point centerPt,
double res)
Centers the map on the given point and zoom into the given resolution level. |
void |
zoomToScale(Point centerPt,
double scale)
Centers the map on the given point and zoom into the given scale level. |
Methods inherited from class android.view.ViewGroup |
---|
addFocusables, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, bringChildToFront, childDrawableStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchConfigurationChanged, dispatchDisplayHint, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, findFocus, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildMeasureSpec, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onInterceptTouchEvent, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, showContextMenuForChild, startLayoutAnimation, updateViewLayout |
Methods inherited from class android.view.View |
---|
bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, computeScroll, createContextMenu, destroyDrawingCache, draw, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getContentDescription, getContext, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getId, getKeepScreenOn, getKeyDispatcherState, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getTag, getTag, getTop, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPressed, isSaveEnabled, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, offsetLeftAndRight, offsetTopAndBottom, onCheckIsTextEditor, onCreateInputConnection, onFinishTemporaryDetach, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onWindowFocusChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollbarFadingEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface android.view.ViewParent |
---|
createContextMenu, getParent, isLayoutRequested, requestLayout |
Constructor Detail |
---|
public MapView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
context
- The Context the view is running in, through which it can access the current theme, resources, and so
on.attrs
- The attributes of the XML tag used to inflate the MapView.defStyle
- the default style to apply to this view. If the value 0 is supplied, then no style will be applied
(beyond what is included in the theme). This may either be an attribute resource, whose value will be
retrieved from the current theme, or an explicit style resource.public MapView(android.content.Context context, android.util.AttributeSet attrs)
context
- The Context the view is running in, through which it can access the current theme, resources and so
on.attrs
- The attributes of the XML tag used to inflate the MapView.public MapView(android.content.Context context)
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.public MapView(android.content.Context context, SpatialReference spatialreference, Envelope extent)
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.spatialreference
- the spatial reference to initialize the map with.extent
- the initial map extent to display.public MapView(android.content.Context context, String url, String user, String passwd)
addLayer(Layer)
in an OnStatusChangedListener
.
Java code sample to add a GraphicsLayer on top of the WebMap:
MapView mv = new MapView(this, "http://www.arcgis.com/home/item.html?id=12345", "myname", "mypassword"); setContentView(mv); mv.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(View source, STATUS status) { if (status == STATUS.INITIALIZED) { // add a graphics layer mv.addLayer(new GraphicsLayer(this, new SimpleRenderer(new SimpleMarkerSymbol(Color.RED, 20, STYLE.DIAMOND)), null, null)); } } });
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.url
- the URL of the WebMapuser
- the name of the user who can access the WebMap. Set to null if the WebMap doesn't need to sign in.passwd
- the password of the user. Set to null if the WebMap doesn't need to sign in.public MapView(android.content.Context context, String url, String user, String passwd, String bingMapsAppId)
addLayer(Layer)
in an OnStatusChangedListener
.
Java code sample to add a GraphicsLayer on top of the WebMap:
MapView mv = new MapView(this, "http://www.arcgis.com/home/item.html?id=12345", "myname", "mypassword"); setContentView(mv); mv.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(View source, STATUS status) { if (status == STATUS.INITIALIZED) { // add a graphics layer mv.addLayer(new GraphicsLayer(this, new SimpleRenderer(new SimpleMarkerSymbol(Color.RED, 20, STYLE.DIAMOND)), null, null)); } } });
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.url
- the URL of the WebMapuser
- the name of the user who can access the WebMap. Set to null if the WebMap doesn't need to sign in.passwd
- the password of the user. Set to null if the WebMap doesn't need to sign in.bingMapsAppId
- if the WebMap is using Bing map, you need to provide the application id to access the map.public MapView(android.content.Context context, String url, String user, String passwd, String bingMapsAppId, OnMapEventListener listener)
addLayer(Layer)
in an OnStatusChangedListener
.
Java code sample to add a GraphicsLayer on top of the WebMap:
MapView mv = new MapView(this, "http://www.arcgis.com/home/item.html?id=12345", "myname", "mypassword"); setContentView(mv); mv.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(View source, STATUS status) { if (status == STATUS.INITIALIZED) { // add a graphics layer mv.addLayer(new GraphicsLayer(this, new SimpleRenderer(new SimpleMarkerSymbol(Color.RED, 20, STYLE.DIAMOND)), null, null)); } } });
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.url
- the URL of the WebMapuser
- the name of the user who can access the WebMap. Set to null if the WebMap doesn't need to sign in.passwd
- the password of the user. Set to null if the WebMap doesn't need to sign in.bingMapsAppId
- if the WebMap is using Bing map, you need to provide the application id to access the map.public MapView(android.content.Context context, WebMap webmap, String bingMapsAppId, OnMapEventListener listener)
addLayer(Layer)
in an OnStatusChangedListener
.
Java code sample to add a GraphicsLayer on top of the WebMap:
MapView mv = new MapView(this, webmap, null, null); setContentView(mv); mv.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; public void onStatusChanged(View source, STATUS status) { if (status == STATUS.INITIALIZED) { // add a graphics layer mv.addLayer(new GraphicsLayer(this, new SimpleRenderer(new SimpleMarkerSymbol(Color.RED, 20, STYLE.DIAMOND)), null, null)); } } });
context
- The Context the view is running in, through which it can access the current theme, resources, , and
so on.webmap
- the WebMapbingMapsAppId
- if the WebMap is using Bing map, you need to provide the application id to access the map.listener
- when fail to load the WebMap, the user can feedback on how to handle the failure. You can set to
null to follow the default loading behavior.Method Detail |
---|
public void zoomin()
public void zoomout()
public android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
generateLayoutParams
in class android.view.ViewGroup
public void onChildViewAdded(android.view.View parent, android.view.View child)
onChildViewAdded
in interface android.view.ViewGroup.OnHierarchyChangeListener
public String retainState()
The following example code illustrates the purpose of this method:
// The onPause() method is being overridden for an Activity // The map object is of type MapView super.onPause(); SharedPreferences.Editor editor = getPreferences(0).edit(); editor.putString("my map status", map.retainState()); editor.commit();See the HelloWorld sample for more details.
public void restoreState(String state)
// The onResume() method is being overridden for an Activity // The map object is of type MapView protected void onResume() { super.onResume(); SharedPreferences prefs = getPreferences(0); map.restoreState(prefs.getString("my map state", "")); }See the HelloWorld sample for more details.
public boolean isAllowRotationByPinch()
public void setAllowRotationByPinch(boolean allowRotationByPinch)
allowRotationByPinch
- flag for allowing rotation by pinch (default: true)public Point getCenter()
public double getResolution()
public void setResolution(double res)
res
- a valid double numberpublic SpatialReference getSpatialReference()
public void removeLayer(Layer layer)
layer
- one of the concrete sub-classes of the MapLayer class (e.g. ArcGISDynamicMapServiceLayer, and so on).public int addLayer(Layer layer)
layer
- one of the concrete sub-classes of the Layer class (e.g. ArcGISDynamicMapServiceLayer, and so on).
public void addLayers(Layer[] layerArray)
layerArray
- a set of the concrete sub-classes of the Layer classes (e.g. ArcGISDynamicMapServiceLayer, and so
on).public int addLayer(Layer layer, int index)
The index position is zero-based, meaning that a value of 0 represents the first Layer to be drawn by the MapView.
An index number out of current index range is not allowed. For instance, if you have 3 layers with index 0, 1, and 2, then you cannot add the next Layer with an index position of 3.
layer
- one of the concrete sub-classes of the Layer class (e.g. ArcGISDynamicMapServiceLayer, and so on).index
- the index position of the Layer.
public void removeLayer(int index)
addLayer(Layer, int)
method for details on the index.
index
- the index position of the Layer.public void removeAll()
public Layer getLayerByURL(String url)
url
- service URL.
public Layer[] getLayers()
public Layer getLayer(int index)
index
- the index position of the Layer.
public void setMapBackground(int bkColor, int gridColor, float gridSize, float gridLineSize)
bkColor
- background color packed as ints.gridColor
- grid color packed as ints.gridSize
- the size of grid.gridLineSize
- the line size of gridpublic Polygon getExtent()
public Envelope getMapBoundaryExtent()
public void setExtent(Geometry geometry)
setExtent(Geometry, int)
method with padding zero.
geometry
- Geometry object(Point, Polygon, Polyline or Envelope);public void setExtent(Geometry geometry, int padding)
geometry
- Geometry object(Point, Polygon, Polyline or Envelope);padding
- non-negative integer (in pixel)public void zoomTo(Point centerPt, float factor)
centerPt
- a point representing the new center of the MapView. The point object must be defined to have the
same spatial coordinate system of the MapView. The spatial coordinate system can be obtained using the
getSpatialReference() method.factor
- represents a factor that is used to calculate and apply a new resolution to the MapView. The new
resolution is equal to the current resolution divided by the factor supplied in the method call (new
resolution = current resolution / factor).public void centerAt(Point centerPt, boolean animated)
centerPt
- a point representing the new center of the MapView. The point object must be defined to have the
same spatial coordinate system of the MapView. The spatial coordinate system can be obtained using the
getSpatialReference() method. The isLoaded() method can be used to determine if the MapView has been
initialized. See isLoaded()
method description for details.animated
- boolean to decide if animation is needed.public Point toScreenPoint(Point src)
src
- the ArcGIS geometry Point that has a spatial coordinate system defined equivalent to that of the
MapView's.
public Point toMapPoint(Point src)
src
- the ArcGIS geometry Point given in screen coordinates.
public Point toMapPoint(float screenx, float screeny)
screenx
- the x coordinate of the device's screen point in pixels.screeny
- the y coordinate of the device's screen point in pixels.
public double getScale()
public void setScale(double scale)
scale
- double valuepublic OnZoomListener getOnZoomListener()
public void setOnZoomListener(OnZoomListener onZoomListener)
onZoomListener
- The OnZoomListener to set.public OnPanListener getOnPanListener()
public void setOnPanListener(OnPanListener onPanListener)
onPanListener
- The OnPanListener to set.public OnLongPressListener getOnLongPressListener()
public void setOnLongPressListener(OnLongPressListener onLongPressListener)
onLongPressListener
- The OnLongPressListener to set.public OnPinchListener getOnPinchListener()
public void setOnPinchListener(OnPinchListener onPinchListener)
onPinchListener
- The onPinchListener to set.public OnSingleTapListener getOnSingleTapListener()
public void setOnSingleTapListener(OnSingleTapListener onSingleTapListener)
onSingleTapListener
- The onSingleTapListener to set.public OnStatusChangedListener getOnStatusChangedListener()
public void setOnStatusChangedListener(OnStatusChangedListener onStatusChangedListener)
onStatusChangedListener
- The OnStatusChangedListener to set.public boolean isLoaded()
public LocationService getLocationService()
public Callout getCallout()
public void recycle()
public void setRotationAngle(double degree)
degree
- double number (in degree)public void setRotationAngle(double degree, float pivotX, float pivotY)
degree
- double number (in degree)pivotX
- a float number (in pixel)pivotY
- a float number (in pixel)public double getRotationAngle()
public void pause()
public void unpause()
public void zoomToScale(Point centerPt, double scale)
centerPt
- a Point objectscale
- a double numberpublic void zoomToResolution(Point centerPt, double res)
centerPt
- a Point objectres
- a double numberpublic void onChildViewRemoved(android.view.View parent, android.view.View child)
onChildViewRemoved
in interface android.view.ViewGroup.OnHierarchyChangeListener
public double getMinResolution()
public void setMinResolution(double minResolution)
minResolution
- The minResolution to set.public double getMaxResolution()
public void setMaxResolution(double maxResolution)
maxResolution
- The maxResolution to set.public Grid getGrid()
Grid
instance of the map which allows for the type and visibility of the grid to be controlled.
Grid
public void setEsriLogoVisible(boolean visible)
visible
- true to turn on the Esri logo on the map.public android.graphics.Bitmap getDrawingMapCache(float x, float y, int w, int h)
x
- the x of the left-upper corner of the cache image in screen coordinatesy
- the y of the left-upper corner of the cache image in screen coordinatesw
- the width of the cache in pixlesh
- the height of the cache in pixlespublic boolean isRecycled()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |