-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.ViewManager,android.view.ViewParent,android.view.accessibility.AccessibilityEventSource,org.metalev.multitouch.controller.MultiTouchController.MultiTouchObjectCanvas,org.osmdroid.api.IMapView
public class MapView extends ViewGroup implements IMapView, MultiTouchController.MultiTouchObjectCanvas<Object>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceMapView.OnFirstLayoutListenerpublic classMapView.LayoutParamsPer-child layout information associated with OpenStreetMapView.
-
Field Summary
Fields Modifier and Type Field Description private floatmapOrientationprivate booleanhorizontalMapRepetitionEnabledprivate booleanverticalMapRepetitionEnabled
-
Constructor Summary
Constructors Constructor Description MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs)MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs, boolean hardwareAccelerated)MapView(Context context, AttributeSet attrs)Constructor used by XML layout resource (uses default tile source). MapView(Context context)MapView(Context context, MapTileProviderBase aTileProvider)MapView(Context context, MapTileProviderBase aTileProvider, Handler tileRequestCompleteHandler)
-
Method Summary
Modifier and Type Method Description floatgetMapOrientation()voidsetMapOrientation(float degrees)rotates the map to the desired heading voidsetHorizontalMapRepetitionEnabled(boolean horizontalMapRepetitionEnabled)If horizontalMapRepetition is enabled the map repeats in left/right direction and scrolling wraps around theedges. voidsetVerticalMapRepetitionEnabled(boolean verticalMapRepetitionEnabled)If verticalMapRepetition is enabled the map repeats in top/bottom direction and scrolling wraps around theedges. IMapControllergetController()List<Overlay>getOverlays()You can add/remove/reorder your Overlays using the List of Overlay. OverlayManagergetOverlayManager()voidsetOverlayManager(OverlayManager overlayManager)MapTileProviderBasegetTileProvider()ScrollergetScroller()HandlergetTileRequestCompleteHandler()doublegetLatitudeSpanDouble()doublegetLongitudeSpanDouble()BoundingBoxgetBoundingBox()RectgetScreenRect(Rect reuse)Gets the current bounds of the screen in screen coordinates. RectgetIntrinsicScreenRect(Rect reuse)ProjectiongetProjection()Get a projection for converting between screen-pixel coordinates and latitude/longitudecoordinates. booleanisTilesScaledToDpi()voidsetTilesScaledToDpi(boolean tilesScaledToDpi)if true, tiles are scaled to the current DPI of the display. floatgetTilesScaleFactor()voidsetTilesScaleFactor(float pTilesScaleFactor)Setting an additional scale factor both for ScaledToDpi and standard size> 1.0 enlarges map display, < 1. voidresetTilesScaleFactor()voidsetTileSource(ITileSource aTileSource)voidzoomToBoundingBox(BoundingBox boundingBox, boolean animated)Zoom the map to enclose the specified bounding box, as closely as possible. doublezoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels, double pMaximumZoom, Long pAnimationSpeed)voidzoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels)intgetZoomLevel()Get the current ZoomLevel for the map tiles. doublegetZoomLevelDouble()doublegetZoomLevel(boolean aPending)Get the current ZoomLevel for the map tiles. doublegetMinZoomLevel()Get the minimum allowed zoom level for the maps. doublegetMaxZoomLevel()Get the maximum allowed zoom level for the maps. voidsetMinZoomLevel(Double zoomLevel)Set the minimum allowed zoom level, or pass null to use the minimum zoom level from the tileprovider. voidsetMaxZoomLevel(Double zoomLevel)Set the maximum allowed zoom level, or pass null to use the maximum zoom level from the tileprovider. booleancanZoomIn()booleancanZoomOut()IGeoPointgetMapCenter()Returns the current center-point position of the map, as a GeoPoint (latitude and longitude). IGeoPointgetMapCenter(GeoPoint pReuse)floatgetMapScale()booleanuseDataConnection()Whether to use the network connection if it's available. voidsetUseDataConnection(boolean aMode)Set whether to use the network connection if it's available. voidsetScrollableAreaLimitDouble(BoundingBox boundingBox)Set the map to limit it's scrollable view to the specified BoundingBox. voidresetScrollableAreaLimitLatitude()voidresetScrollableAreaLimitLongitude()voidsetScrollableAreaLimitLatitude(double pNorth, double pSouth, int pExtraPixelHeight)sets the scroll limitExample:To block vertical scroll of the view outside north/south poles:mapView.setScrollableAreaLimitLatitude(MapView.getTileSystem().getMaxLatitude(),MapView.getTileSystem().getMinLatitude(),0);Warning:Don't use latitude values outside the [MapView.getTileSystem().getMinLatitude(),MapView.getTileSystem().getMaxLatitude()] range, this would cause an ANR. voidsetScrollableAreaLimitLongitude(double pWest, double pEast, int pExtraPixelWidth)sets the scroll limit booleanisScrollableAreaLimitLatitude()booleanisScrollableAreaLimitLongitude()voidinvalidateMapCoordinates(Rect dirty)voidinvalidateMapCoordinates(int left, int top, int right, int bottom)voidpostInvalidateMapCoordinates(int left, int top, int right, int bottom)ViewGroup.LayoutParamsgenerateLayoutParams(AttributeSet attrs)voidaddOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)enables you to add a listener for when the map is ready to go. voidremoveOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)booleanisLayoutOccurred()voidonAttachedToWindow()voidonPause()activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc voidonResume()activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc voidonDetach()destroys the map view, all references to listeners, all overlays, etc booleanonKeyDown(int keyCode, KeyEvent event)booleanonKeyUp(int keyCode, KeyEvent event)booleanonTrackballEvent(MotionEvent event)booleandispatchTouchEvent(MotionEvent event)booleanonTouchEvent(MotionEvent event)voidcomputeScroll()voidscrollTo(int x, int y)voidscrollBy(int x, int y)voidsetBackgroundColor(int pColor)booleanisAnimating()Determines if maps are animating a zoom operation. ObjectgetDraggableObjectAtPoint(MultiTouchController.PointInfo pt)See if there is a draggable object at the current point. voidgetPositionAndScale(Object obj, MultiTouchController.PositionAndScale objPosAndScaleOut)Get the screen coords of the dragged object's origin, and scale multiplier to convert screen coords to obj coords. voidselectObject(Object obj, MultiTouchController.PointInfo pt)Select an object at the given point. booleansetPositionAndScale(Object obj, MultiTouchController.PositionAndScale aNewObjPosAndScale, MultiTouchController.PointInfo aTouchPoint)Callback to update the position and scale (in object coords) of the currently-dragged object. voidresetMultiTouchScale()voidsetMapListener(MapListener ml)voidaddMapListener(MapListener mapListener)Just like the old setMapListener, except it supports more than one voidremoveMapListener(MapListener mapListener)Removes a map listener voidsetBuiltInZoomControls(boolean on)voidsetMultiTouchControls(boolean on)booleanisHorizontalMapRepetitionEnabled()booleanisVerticalMapRepetitionEnabled()voidsetFlingEnabled(boolean b)booleanisFlingEnabled()voidsetTileProvider(MapTileProviderBase base)enables you to programmatically set the tile provider (zip, assets, sqlite, etc) voidsetInitCenter(IGeoPoint geoPoint)Sets the initial center point of the map. longgetMapScrollX()longgetMapScrollY()voidsetExpectedCenter(IGeoPoint pGeoPoint, long pOffsetX, long pOffsetY)Deferred setting of the expected next map center computed by the Projection's constructor,with no guarantee it will be 100% respected. voidsetExpectedCenter(IGeoPoint pGeoPoint)voidsetZoomRounding(boolean pZoomRounding)static TileSystemgetTileSystem()static voidsetTileSystem(TileSystem pTileSystem)MapViewRepositorygetRepository()CustomZoomButtonsControllergetZoomController()TilesOverlaygetMapOverlay()voidsetDestroyMode(boolean pOnDetach)intgetMapCenterOffsetX()intgetMapCenterOffsetY()voidsetMapCenterOffset(int pMapCenterOffsetX, int pMapCenterOffsetY)-
Methods inherited from class android.view.ViewGroup
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchCreateViewTranslationRequest, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchScrollCaptureSearch, dispatchSetActivated, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, endViewTransition, findFocus, findViewsWithText, focusSearch, focusableViewAvailable, gatherTransparentRegion, generateLayoutParams, getAccessibilityClassName, getChildAt, getChildCount, getChildMeasureSpec, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onDescendantInvalidated, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setTouchscreenBlocksFocus, setTransitionGroup, setWindowInsetsAnimationCallback, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout -
Methods inherited from class android.view.View
addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, bringToFront, buildDrawingCache, buildLayer, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, clearViewTranslationCallback, combineMeasuredStates, computeScroll, computeSystemWindowInsets, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, forceHasOverlappingRendering, forceLayout, generateDisplayHash, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getOverlay, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getReceiveContentMimeTypes, getResources, getRevealOnFocusHint, getRight, getRootSurfaceControl, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollCaptureHint, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTouchDelegate, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTranslationResponse, getViewTreeObserver, getVisibility, getWidth, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, offsetLeftAndRight, offsetTopAndBottom, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onCreateInputConnection, onCreateViewTranslationRequest, onCreateVirtualViewTranslationRequests, onDragEvent, onDrawForeground, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onReceiveContent, onRtlPropertiesChanged, onScreenStateChanged, onScrollCaptureSearch, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onViewTranslationResponse, onVirtualViewTranslationResponses, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performLongClick, performReceiveContent, playSoundEffect, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAllowClickWhenDisabled, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnReceiveContentListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRenderEffect, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollBarSize, setScrollBarStyle, setScrollCaptureCallback, setScrollCaptureHint, setScrollContainer, setScrollIndicators, setScrollX, setScrollY, setScrollbarFadingEnabled, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setViewTranslationCallback, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw -
Methods inherited from class org.osmdroid.api.IMapView
getProjection, setBackgroundColor -
Methods inherited from class org.metalev.multitouch.controller.MultiTouchController.MultiTouchObjectCanvas
getDraggableObjectAtPoint, getPositionAndScale, selectObject, setPositionAndScale -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MapView
MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs)
-
MapView
MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs, boolean hardwareAccelerated)
-
MapView
MapView(Context context, AttributeSet attrs)
Constructor used by XML layout resource (uses default tile source).
-
MapView
MapView(Context context)
-
MapView
MapView(Context context, MapTileProviderBase aTileProvider)
-
MapView
MapView(Context context, MapTileProviderBase aTileProvider, Handler tileRequestCompleteHandler)
-
-
Method Detail
-
getMapOrientation
float getMapOrientation()
-
setMapOrientation
void setMapOrientation(float degrees)
rotates the map to the desired heading
-
setHorizontalMapRepetitionEnabled
void setHorizontalMapRepetitionEnabled(boolean horizontalMapRepetitionEnabled)
If horizontalMapRepetition is enabled the map repeats in left/right direction and scrolling wraps around theedges. If disabled the map is only shown once for the horizontal direction. Default is true.
-
setVerticalMapRepetitionEnabled
void setVerticalMapRepetitionEnabled(boolean verticalMapRepetitionEnabled)
If verticalMapRepetition is enabled the map repeats in top/bottom direction and scrolling wraps around theedges. If disabled the map is only shown once for the vertical direction. Default is true.
-
getController
IMapController getController()
-
getOverlays
List<Overlay> getOverlays()
You can add/remove/reorder your Overlays using the List of Overlay. The first (index0) Overlay gets drawn first, the one with the highest as the last one.
-
getOverlayManager
OverlayManager getOverlayManager()
-
setOverlayManager
void setOverlayManager(OverlayManager overlayManager)
-
getTileProvider
MapTileProviderBase getTileProvider()
-
getScroller
Scroller getScroller()
-
getTileRequestCompleteHandler
Handler getTileRequestCompleteHandler()
-
getLatitudeSpanDouble
double getLatitudeSpanDouble()
-
getLongitudeSpanDouble
double getLongitudeSpanDouble()
-
getBoundingBox
BoundingBox getBoundingBox()
-
getScreenRect
Rect getScreenRect(Rect reuse)
Gets the current bounds of the screen in screen coordinates.
-
getIntrinsicScreenRect
Rect getIntrinsicScreenRect(Rect reuse)
-
getProjection
Projection getProjection()
Get a projection for converting between screen-pixel coordinates and latitude/longitudecoordinates. You should not hold on to this object for more than one draw, since theprojection of the map could change.
-
isTilesScaledToDpi
boolean isTilesScaledToDpi()
-
setTilesScaledToDpi
void setTilesScaledToDpi(boolean tilesScaledToDpi)
if true, tiles are scaled to the current DPI of the display. This effectivelymakes it easier to read labels, how it may appear pixelated depending on the mapsource.if false, tiles are rendered in their real size
-
getTilesScaleFactor
float getTilesScaleFactor()
-
setTilesScaleFactor
void setTilesScaleFactor(float pTilesScaleFactor)
Setting an additional scale factor both for ScaledToDpi and standard size> 1.0 enlarges map display, < 1.0 shrinks map display
-
resetTilesScaleFactor
void resetTilesScaleFactor()
-
setTileSource
void setTileSource(ITileSource aTileSource)
-
zoomToBoundingBox
void zoomToBoundingBox(BoundingBox boundingBox, boolean animated)
Zoom the map to enclose the specified bounding box, as closely as possible. Must be calledafter display layout is complete, or screen dimensions are not known, and will always zoom tocenter of zoom level 0.Suggestion: Check getIntrinsicScreenRect(null).getHeight() > 0
-
zoomToBoundingBox
double zoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels, double pMaximumZoom, Long pAnimationSpeed)
- Parameters:
pBoundingBox- Bounding box we want to zoom to; may be a single GeoPointpAnimated- Animation or immediate action?pBorderSizeInPixels- Border size around the bounding boxpMaximumZoom- Maximum zoom we want from bounding box computationpAnimationSpeed- Animation duration, in milliseconds
-
zoomToBoundingBox
void zoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels)
-
getZoomLevel
@Deprecated() int getZoomLevel()
Get the current ZoomLevel for the map tiles.
-
getZoomLevelDouble
double getZoomLevelDouble()
-
getZoomLevel
@Deprecated() double getZoomLevel(boolean aPending)
Get the current ZoomLevel for the map tiles.
- Parameters:
aPending- if true and we're animating then return the zoom level that we're animatingtowards, otherwise return the current zoom levelUsed to be an int - is a double since 6.
-
getMinZoomLevel
double getMinZoomLevel()
Get the minimum allowed zoom level for the maps.
-
getMaxZoomLevel
double getMaxZoomLevel()
Get the maximum allowed zoom level for the maps.
-
setMinZoomLevel
void setMinZoomLevel(Double zoomLevel)
Set the minimum allowed zoom level, or pass null to use the minimum zoom level from the tileprovider.
-
setMaxZoomLevel
void setMaxZoomLevel(Double zoomLevel)
Set the maximum allowed zoom level, or pass null to use the maximum zoom level from the tileprovider.
-
canZoomIn
boolean canZoomIn()
-
canZoomOut
boolean canZoomOut()
-
getMapCenter
IGeoPoint getMapCenter()
Returns the current center-point position of the map, as a GeoPoint (latitude and longitude).Gives you the actual current map center, as the Projection computes it from the middle ofthe screen. Most of the time it's supposed to be approximately the same value (becauseof computing rounding side effects), but in some cases (current zoom gesture or scrolllimits) the values may differ (typically, when adjustOffsets had to fine-tunethe map center).
-
getMapCenter
IGeoPoint getMapCenter(GeoPoint pReuse)
-
getMapScale
@Deprecated() float getMapScale()
-
useDataConnection
boolean useDataConnection()
Whether to use the network connection if it's available.
-
setUseDataConnection
void setUseDataConnection(boolean aMode)
Set whether to use the network connection if it's available.
- Parameters:
aMode- if true use the network connection if it's available.
-
setScrollableAreaLimitDouble
void setScrollableAreaLimitDouble(BoundingBox boundingBox)
Set the map to limit it's scrollable view to the specified BoundingBox. Note this does notlimit zooming so it will be possible for the user to zoom out to an area that is larger than thelimited area.
- Parameters:
boundingBox- A lat/long bounding box to limit scrolling to, or null to remove any scrollinglimitations
-
resetScrollableAreaLimitLatitude
void resetScrollableAreaLimitLatitude()
-
resetScrollableAreaLimitLongitude
void resetScrollableAreaLimitLongitude()
-
setScrollableAreaLimitLatitude
void setScrollableAreaLimitLatitude(double pNorth, double pSouth, int pExtraPixelHeight)
sets the scroll limitExample:To block vertical scroll of the view outside north/south poles:mapView.setScrollableAreaLimitLatitude(MapView.getTileSystem().getMaxLatitude(),MapView.getTileSystem().getMinLatitude(),0);Warning:Don't use latitude values outside the [MapView.getTileSystem().getMinLatitude(),MapView.getTileSystem().getMaxLatitude()] range, this would cause an ANR.
- Parameters:
pNorth- decimal degrees latitudepSouth- decimal degrees latitudepExtraPixelHeight- in pixels, enables scrolling this many pixels past the bounds
-
setScrollableAreaLimitLongitude
void setScrollableAreaLimitLongitude(double pWest, double pEast, int pExtraPixelWidth)
sets the scroll limit
- Parameters:
pWest- decimal degrees longitudepEast- decimal degrees longitudepExtraPixelWidth- in pixels, enables scrolling this many pixels past the bounds
-
isScrollableAreaLimitLatitude
boolean isScrollableAreaLimitLatitude()
-
isScrollableAreaLimitLongitude
boolean isScrollableAreaLimitLongitude()
-
invalidateMapCoordinates
void invalidateMapCoordinates(Rect dirty)
-
invalidateMapCoordinates
void invalidateMapCoordinates(int left, int top, int right, int bottom)
-
postInvalidateMapCoordinates
void postInvalidateMapCoordinates(int left, int top, int right, int bottom)
-
generateLayoutParams
ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
-
addOnFirstLayoutListener
void addOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)
enables you to add a listener for when the map is ready to go.
-
removeOnFirstLayoutListener
void removeOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)
-
isLayoutOccurred
boolean isLayoutOccurred()
-
onAttachedToWindow
void onAttachedToWindow()
-
onPause
void onPause()
activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc
-
onResume
void onResume()
activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc
-
onDetach
void onDetach()
destroys the map view, all references to listeners, all overlays, etc
-
onTrackballEvent
boolean onTrackballEvent(MotionEvent event)
-
dispatchTouchEvent
boolean dispatchTouchEvent(MotionEvent event)
-
onTouchEvent
boolean onTouchEvent(MotionEvent event)
-
computeScroll
void computeScroll()
-
scrollTo
void scrollTo(int x, int y)
-
scrollBy
void scrollBy(int x, int y)
-
setBackgroundColor
void setBackgroundColor(int pColor)
-
isAnimating
boolean isAnimating()
Determines if maps are animating a zoom operation. Useful for overlays to avoid recalculatingduring an animation sequence.
-
getDraggableObjectAtPoint
Object getDraggableObjectAtPoint(MultiTouchController.PointInfo pt)
See if there is a draggable object at the current point. Returns the object at the point, or null if nothing to drag. To start a multitouchdrag/stretch operation, this routine must return some non-null reference to an object. This object is passed into the other methods in thisinterface when they are called.
-
getPositionAndScale
void getPositionAndScale(Object obj, MultiTouchController.PositionAndScale objPosAndScaleOut)
Get the screen coords of the dragged object's origin, and scale multiplier to convert screen coords to obj coords. The job of this routineis to call the .set() method on the passed PositionAndScale object to record the initial position and scale of the object (in objectcoordinates) before any dragging/stretching takes place.
- Parameters:
obj- The object being dragged/stretched.objPosAndScaleOut- Output parameter: You need to call objPosAndScaleOut.set() to record the current position and scale of obj.
-
selectObject
void selectObject(Object obj, MultiTouchController.PointInfo pt)
Select an object at the given point. Can be used to bring the object to top etc. Only called when first touchpoint goes down, not whenmultitouch is initiated. Also called with null on touch-up.
- Parameters:
obj- The object being selected by single-touch, or null on touch-up.
-
setPositionAndScale
boolean setPositionAndScale(Object obj, MultiTouchController.PositionAndScale aNewObjPosAndScale, MultiTouchController.PointInfo aTouchPoint)
Callback to update the position and scale (in object coords) of the currently-dragged object.
- Parameters:
obj- The object being dragged/stretched.
-
resetMultiTouchScale
void resetMultiTouchScale()
-
setMapListener
@Deprecated() void setMapListener(MapListener ml)
-
addMapListener
void addMapListener(MapListener mapListener)
Just like the old setMapListener, except it supports more than one
-
removeMapListener
void removeMapListener(MapListener mapListener)
Removes a map listener
-
setBuiltInZoomControls
@Deprecated() void setBuiltInZoomControls(boolean on)
-
setMultiTouchControls
void setMultiTouchControls(boolean on)
-
isHorizontalMapRepetitionEnabled
boolean isHorizontalMapRepetitionEnabled()
-
isVerticalMapRepetitionEnabled
boolean isVerticalMapRepetitionEnabled()
-
setFlingEnabled
void setFlingEnabled(boolean b)
-
isFlingEnabled
boolean isFlingEnabled()
-
setTileProvider
void setTileProvider(MapTileProviderBase base)
enables you to programmatically set the tile provider (zip, assets, sqlite, etc)
-
setInitCenter
@Deprecated() void setInitCenter(IGeoPoint geoPoint)
Sets the initial center point of the map. This can be set before the map view is 'ready'meaning that it can be set and honored with the onFirstLayoutListener
-
getMapScrollX
long getMapScrollX()
-
getMapScrollY
long getMapScrollY()
-
setExpectedCenter
void setExpectedCenter(IGeoPoint pGeoPoint, long pOffsetX, long pOffsetY)
Deferred setting of the expected next map center computed by the Projection's constructor,with no guarantee it will be 100% respected.see issue 868
-
setExpectedCenter
void setExpectedCenter(IGeoPoint pGeoPoint)
-
setZoomRounding
void setZoomRounding(boolean pZoomRounding)
-
getTileSystem
static TileSystem getTileSystem()
-
setTileSystem
static void setTileSystem(TileSystem pTileSystem)
-
getRepository
MapViewRepository getRepository()
-
getZoomController
CustomZoomButtonsController getZoomController()
-
getMapOverlay
TilesOverlay getMapOverlay()
-
setDestroyMode
void setDestroyMode(boolean pOnDetach)
-
getMapCenterOffsetX
int getMapCenterOffsetX()
-
getMapCenterOffsetY
int getMapCenterOffsetY()
-
setMapCenterOffset
void setMapCenterOffset(int pMapCenterOffsetX, int pMapCenterOffsetY)
-
-
-
-