|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.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 LayerView as its child. In general, the MapView is the parent
of all LayerView 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 LayerView. 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 "World Street Map" 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">
<com.esri.android.map.ags.ArcGISTiledMapServiceLayer
url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</com.esri.android.map.MapView>
Java usage:
//ArcGISTiledMapServiceLayer class is used to define the LayerView that is added to the
//MapView object.
MapView mv = new MapView(this);
mv.addLayer(new ArcGISTiledMapServiceLayer(this,
"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.
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) {
Log.d("Test", "resolution:" + map.getResolution());
}
}
});
}
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 | |
|---|---|
static long |
CONTEXT_TILE_CACHE_SIZE
Defines the disk space (in KB) for tile cache on the internal directory. |
static String |
EXTERNAL_CACHE_DIR_NAME
Defines the name of the directory for tile caching on the external storage (e.g. |
static boolean |
EXTERNAL_TILE_CACHE_ENABLED
Enables the external storage for tile caching. |
static long |
EXTERNAL_TILE_CACHE_SIZE
Defines the disk space (in KB) for tile cache on the external storage (e.g. |
static int |
TILE_FILE_KB_SIZE
Defines the average size (in KB) of a cached tile. |
| Fields inherited from class android.view.ViewGroup |
|---|
CLIP_TO_PADDING_MASK, 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, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET |
| 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,
String url,
String user,
String passwd)
The constructor is used if you are instantiating the MapView using the URL of a WebMap. |
|
| Method Summary | |
|---|---|
void |
addLayer(LayerView<?> layer)
Adds the child LayerView to the parent, MapView. |
void |
addLayer(LayerView<?> layer,
int index)
Adds the child LayerView at the given index supplied in the method call. |
void |
addLayers(LayerView<?>[] layerArray)
Adds the LayerView array to the parent MapView. |
void |
centerAt(Point centerPt)
If the MapView is initialized, then the centerPt is used to reposition the MapView to make this point the center of the device's display. |
android.view.ViewGroup.LayoutParams |
generateLayoutParams(android.util.AttributeSet attrs)
|
Callout |
getCallout()
Returns the unique instance of the callout window |
Point |
getCenter()
Returns the center of the MapView as an ArcGIS geometry Point. |
Envelope |
getExtent()
Returns an extent representing the maximum extent of data, which is currently visible on the device that is showing the map. |
LayerView<?> |
getLayerById(int resourceId)
Gets a layer by its resource id. |
LayerView<?>[] |
getLayers()
Returns all child LayerViews that are added to the MapView. |
LocationService |
getLocationService()
Returns the unique instance of the location service |
OnMapExtentChangedListener |
getOnExtentChangedListener()
Gets the onExtentChangedListener of the MapView. |
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. |
SpatialReference |
getSpatialReference()
Returns the spatial coordinate system being used by the MapView. |
boolean |
isLoaded()
Returns true if the MapView is initialized. |
void |
onChildViewAdded(android.view.View parent,
android.view.View child)
|
void |
onChildViewRemoved(android.view.View parent,
android.view.View child)
|
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b)
|
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
|
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
|
void |
removeAll()
Removes all child views from the MapView map view. |
void |
removeLayer(int index)
Removes a child layer at the index position passed into the method. |
void |
removeLayerById(int resourceId)
Removes a layer by its resource id. |
void |
reorderLayer(int resourceId,
int index)
Changes the index position of the layer with the resource id supplied in the method. |
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 |
setExtent(Envelope extent)
If the MapView is initialized, then the extent of the map that is displayed on the device will change to the extent that is supplied in this method call. |
void |
setOnExtentChangedListener(OnMapExtentChangedListener onExtentChangedListener)
Sets the onExtentChangedListener of the MapView. |
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. |
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 |
zoomin()
Zooms In one level from current map resolution. |
void |
zoomout()
Zooms Out one level from current map resolution. |
void |
zoomTo(Envelope extent)
Changes the map bounds to the given extent if the MapView is initialized. |
void |
zoomTo(Point centerPt,
float factor)
If the MapView is initialized, then the extent of the map that is displayed on the device will center itself at the point and re-factor based on the supplied parameters in the method call. |
| Methods inherited from class android.view.ViewGroup |
|---|
addFocusables, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, checkLayoutParams, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, findFocus, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, generateDefaultLayoutParams, generateLayoutParams, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, setStaticTransformationsEnabled, showContextMenuForChild, startLayoutAnimation, updateViewLayout |
| Methods inherited from class android.view.View |
|---|
awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, destroyDrawingCache, draw, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getKeyDispatcherState, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTag, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPaddingOffsetRequired, isPressed, isSaveEnabled, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindow, onDisplayHint, onDraw, onDrawScrollBars, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, 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, setMeasuredDimension, 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, verifyDrawable, willNotCacheDrawing, willNotDraw |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface android.view.ViewParent |
|---|
createContextMenu, getParent, isLayoutRequested, requestLayout |
| Field Detail |
|---|
public static long EXTERNAL_TILE_CACHE_SIZE
public static boolean EXTERNAL_TILE_CACHE_ENABLED
public static String EXTERNAL_CACHE_DIR_NAME
public static long CONTEXT_TILE_CACHE_SIZE
public static int TILE_FILE_KB_SIZE
EXTERNAL_TILE_CACHE_SIZE / TILE_FILE_KB_SIZE) or (
CONTEXT_TILE_CACHE_SIZE / TILE_FILE_KB_SIZE) The default value is 50 (KB).
| 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,
String url,
String user,
String passwd)
addLayer(LayerView) 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.| 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 void onChildViewRemoved(android.view.View parent,
android.view.View child)
onChildViewRemoved in interface android.view.ViewGroup.OnHierarchyChangeListener
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
onMeasure in class android.view.View
protected void onLayout(boolean changed,
int l,
int t,
int r,
int b)
onLayout in class android.view.ViewGrouppublic 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.
protected void onSizeChanged(int w,
int h,
int oldw,
int oldh)
onSizeChanged in class android.view.Viewpublic Point getCenter()
public double getResolution()
public SpatialReference getSpatialReference()
public void addLayer(LayerView<?> layer)
layer - one of the concrete sub-classes of the LayerView class (e.g. ArcGISDynamicMapServiceLayer, and so on).public void addLayers(LayerView<?>[] layerArray)
layerArray - a set of the concrete sub-classes of the LayerView classes (e.g. ArcGISDynamicMapServiceLayer,
and so on).
public void addLayer(LayerView<?> layer,
int index)
The index position is zero-based, meaning that a value of 0 represents the first LayerView to be drawn by the MapView.
Additionally, the index is sequential. For instance, if you have 3 layers with index 0, 1, and 2, then you cannot add the next LayerView with an index position of 5. In this case you must supply an index position of 3, which is the next integer in sequence.
layer - one of the concrete sub-classes of the LayerView class (e.g. ArcGISDynamicMapServiceLayer, and so on).index - the index position of the LayerView.public void removeLayer(int index)
addLayer(LayerView, int)
method for details on the index.
index - the index position of the LayerView.public void removeAll()
public void removeLayerById(int resourceId)
map.removeLayerById(R.id.baselayer);
resourceId - the resource id of the layer specified in the associated layout XML that you, the developer, will
specify when defining your XMLpublic LayerView<?> getLayerById(int resourceId)
public LayerView<?>[] getLayers()
public void reorderLayer(int resourceId,
int index)
resourceId - the resource id of the layer specified in the associated layout XML.index - the index position you want to move the layer too.public Envelope getExtent()
public void setExtent(Envelope extent)
If you pass in an extent that goes outside the boundaries of the device, then the framework will re-draw the map to fit correctly on the device it is being displayed on.
Note: If you attempt to set an extent that is larger or smaller than what the current extent of the device is, the method will take an additional step to correct the aspect ratio of your new extent, which you can get the adjusted Extent by calling getExtent().
extent - the extent 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.public void zoomTo(Envelope extent)
extent - the extent must in the same coordinates of the map.
public void zoomTo(Point centerPt,
float factor)
Define the center point using ArcGIS geometry's Point.
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)
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.public Point toScreenPoint(Point src)
src - the point on the map .
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 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 OnMapExtentChangedListener getOnExtentChangedListener()
public void setOnExtentChangedListener(OnMapExtentChangedListener onExtentChangedListener)
onExtentChangedListener - The onExtentChangedListener to set.public boolean isLoaded()
public LocationService getLocationService()
public Callout getCallout()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||