Package 

Class MapView

  • 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>
                        

    This is the primary view for osmdroid. As of version 6.0.0, please respect the android view lifecycle by calling onPause and onResume respectively

    • Method Summary

      Modifier and Type Method Description
      float getMapOrientation()
      void setMapOrientation(float degrees) rotates the map to the desired heading
      void setHorizontalMapRepetitionEnabled(boolean horizontalMapRepetitionEnabled) If horizontalMapRepetition is enabled the map repeats in left/right direction and scrolling wraps around theedges.
      void setVerticalMapRepetitionEnabled(boolean verticalMapRepetitionEnabled) If verticalMapRepetition is enabled the map repeats in top/bottom direction and scrolling wraps around theedges.
      IMapController getController()
      List<Overlay> getOverlays() You can add/remove/reorder your Overlays using the List of Overlay.
      OverlayManager getOverlayManager()
      void setOverlayManager(OverlayManager overlayManager)
      MapTileProviderBase getTileProvider()
      Scroller getScroller()
      Handler getTileRequestCompleteHandler()
      double getLatitudeSpanDouble()
      double getLongitudeSpanDouble()
      BoundingBox getBoundingBox()
      Rect getScreenRect(Rect reuse) Gets the current bounds of the screen in screen coordinates.
      Rect getIntrinsicScreenRect(Rect reuse)
      Projection getProjection() Get a projection for converting between screen-pixel coordinates and latitude/longitudecoordinates.
      boolean isTilesScaledToDpi()
      void setTilesScaledToDpi(boolean tilesScaledToDpi) if true, tiles are scaled to the current DPI of the display.
      float getTilesScaleFactor()
      void setTilesScaleFactor(float pTilesScaleFactor) Setting an additional scale factor both for ScaledToDpi and standard size> 1.0 enlarges map display, < 1.
      void resetTilesScaleFactor()
      void setTileSource(ITileSource aTileSource)
      void zoomToBoundingBox(BoundingBox boundingBox, boolean animated) Zoom the map to enclose the specified bounding box, as closely as possible.
      double zoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels, double pMaximumZoom, Long pAnimationSpeed)
      void zoomToBoundingBox(BoundingBox pBoundingBox, boolean pAnimated, int pBorderSizeInPixels)
      int getZoomLevel() Get the current ZoomLevel for the map tiles.
      double getZoomLevelDouble()
      double getZoomLevel(boolean aPending) Get the current ZoomLevel for the map tiles.
      double getMinZoomLevel() Get the minimum allowed zoom level for the maps.
      double getMaxZoomLevel() Get the maximum allowed zoom level for the maps.
      void setMinZoomLevel(Double zoomLevel) Set the minimum allowed zoom level, or pass null to use the minimum zoom level from the tileprovider.
      void setMaxZoomLevel(Double zoomLevel) Set the maximum allowed zoom level, or pass null to use the maximum zoom level from the tileprovider.
      boolean canZoomIn()
      boolean canZoomOut()
      IGeoPoint getMapCenter() Returns the current center-point position of the map, as a GeoPoint (latitude and longitude).
      IGeoPoint getMapCenter(GeoPoint pReuse)
      float getMapScale()
      boolean useDataConnection() Whether to use the network connection if it's available.
      void setUseDataConnection(boolean aMode) Set whether to use the network connection if it's available.
      void setScrollableAreaLimitDouble(BoundingBox boundingBox) Set the map to limit it's scrollable view to the specified BoundingBox.
      void resetScrollableAreaLimitLatitude()
      void resetScrollableAreaLimitLongitude()
      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.
      void setScrollableAreaLimitLongitude(double pWest, double pEast, int pExtraPixelWidth) sets the scroll limit
      boolean isScrollableAreaLimitLatitude()
      boolean isScrollableAreaLimitLongitude()
      void invalidateMapCoordinates(Rect dirty)
      void invalidateMapCoordinates(int left, int top, int right, int bottom)
      void postInvalidateMapCoordinates(int left, int top, int right, int bottom)
      ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
      void addOnFirstLayoutListener(MapView.OnFirstLayoutListener listener) enables you to add a listener for when the map is ready to go.
      void removeOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)
      boolean isLayoutOccurred()
      void onAttachedToWindow()
      void onPause() activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc
      void onResume() activities/fragments using osmdroid should call this to release resources, pause gps, sensors, timers, etc
      void onDetach() destroys the map view, all references to listeners, all overlays, etc
      boolean onKeyDown(int keyCode, KeyEvent event)
      boolean onKeyUp(int keyCode, KeyEvent event)
      boolean onTrackballEvent(MotionEvent event)
      boolean dispatchTouchEvent(MotionEvent event)
      boolean onTouchEvent(MotionEvent event)
      void computeScroll()
      void scrollTo(int x, int y)
      void scrollBy(int x, int y)
      void setBackgroundColor(int pColor)
      boolean isAnimating() Determines if maps are animating a zoom operation.
      Object getDraggableObjectAtPoint(MultiTouchController.PointInfo pt) See if there is a draggable object at the current point.
      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.
      void selectObject(Object obj, MultiTouchController.PointInfo pt) Select an object at the given point.
      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.
      void resetMultiTouchScale()
      void setMapListener(MapListener ml)
      void addMapListener(MapListener mapListener) Just like the old setMapListener, except it supports more than one
      void removeMapListener(MapListener mapListener) Removes a map listener
      void setBuiltInZoomControls(boolean on)
      void setMultiTouchControls(boolean on)
      boolean isHorizontalMapRepetitionEnabled()
      boolean isVerticalMapRepetitionEnabled()
      void setFlingEnabled(boolean b)
      boolean isFlingEnabled()
      void setTileProvider(MapTileProviderBase base) enables you to programmatically set the tile provider (zip, assets, sqlite, etc)
      void setInitCenter(IGeoPoint geoPoint) Sets the initial center point of the map.
      long getMapScrollX()
      long getMapScrollY()
      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.
      void setExpectedCenter(IGeoPoint pGeoPoint)
      void setZoomRounding(boolean pZoomRounding)
      static TileSystem getTileSystem()
      static void setTileSystem(TileSystem pTileSystem)
      MapViewRepository getRepository()
      CustomZoomButtonsController getZoomController()
      TilesOverlay getMapOverlay()
      void setDestroyMode(boolean pOnDetach)
      int getMapCenterOffsetX()
      int getMapCenterOffsetY()
      void setMapCenterOffset(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