public class MapView extends android.view.ViewGroup implements MapRenderer.Listener, android.opengl.GLSurfaceView.Renderer, android.view.View.OnTouchListener
MapView
是一个继承自ViewGroup
的控件GLSurfaceView.Renderer
、
MapRenderer.Listener
和View.OnTouchListener
接口Activity
或其子类,必须在
Activity.onPause()
,
Activity.onResume()
,
Activity.onDestroy()
三个方法中调用MapView
对应的三个同名方法。
// <!-- 使用小地图的资源文件示例 -->
// <?xml version="1.0" encoding="utf-8"?>
// <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
// android:id="@+id/main"
// android:layout_width="match_parent"
// android:layout_height="match_parent"
// android:background="#f7efef" >
// <!-- MapView或其子类 -->
// <!-- smallView为boolean类型,可以设置为true或者false,true表示使用小地图,默认不设置此项也表示不使用小地图窗口 -->
// <!-- smallViewLeft/Top/Right/Bottom 分别表示小地图窗口所在位置边界 -->
// <!-- smallViewEnableEvent为boolean类型
// 表示小窗口是否接收事件相应,如果true,表示接收,那么被小窗口覆盖的部分将仅可以操作小地图,不设置默认为false -->
// <!-- 启用小窗口后,默认会显示,如果想隐藏或者修改是否响应事件可以通过制定的API -->
// <!--
// useBuiltInControl为boolean类型,true时表示使用内置的控件,包括比例尺、缩放和指南针,默认不设置此项表示不适用内置的控件 -->
// <!-- 使用内置的控件后,继承onLayout(boolean, int, int, int, int)
实现自定义的布局 -->
// <com.mapbar.DemoMapView
// android:id="@+id/demoMap"
// android:layout_width="fill_parent"
// android:layout_height="fill_parent"
// android:clickable="true"
// smallView="true"
// smallViewLeft="0"
// smallViewTop="0"
// smallViewRight="300"
// smallViewBottom="300"
// smallViewEnableEvent="true"
// useBuiltInControl="true" />
// </RelativeLayout>
// 应用程序中包含MapView的Activity相关方法调用示例
public class DemoMapActivity extends Activity {
private MapView mMapView;
@Override
public void onCreate(Bundle savedInstanceState) {
// 其他初始化操作,如初始化引擎基础环境
// ...
// 通过资源获取地图控件
MapView mMapView = (MapView) findViewById(R.id.demoMap);
// 其他操作
// ...
}
@Override
public void onPause() {
super.onPause();
// 其他操作
// 暂停地图
if (mMapView != null) {
mMapView.onPause();
}
// 其他操作
}
@Override
public void onResume() {
super.onResume();
// 其他操作
// 恢复地图
if (mMapView != null) {
mMapView.onResume();
}
// 其他操作
}
@Override
public void onDestroy() {
super.onDestroy();
if (mMapView != null) {
// 此Activity销毁时,销毁地图控件
mMapView.onDestroy();
}
mMapView = null;
// 其它资源的清理
// ...
}
}
限定符和类型 | 类和说明 |
---|---|
static interface |
MapView.OnDrawListener
绘图事件监听
|
android.view.ViewGroup.LayoutParams, android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
android.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnCapturedPointerListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener, android.view.View.OnUnhandledKeyEventListener
限定符和类型 | 字段和说明 |
---|---|
java.lang.String |
mName |
FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VISIBLE, X, Y, Z
构造器和说明 |
---|
MapView(android.content.Context context)
构造方法
|
MapView(android.content.Context context,
android.util.AttributeSet attrs)
构造方法
|
MapView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle)
构造方法
|
MapView(android.content.Context context,
boolean useSmallMapView,
android.graphics.Rect smallViewPort)
构造方法
|
MapView(android.content.Context context,
boolean useSmallMapView,
android.graphics.Rect smallViewPort,
boolean useBuilitInControl)
构造方法
|
限定符和类型 | 方法和说明 |
---|---|
void |
addOnDrawListener(MapView.OnDrawListener listener)
添加绘制监听
|
void |
destroyMapRenderer() |
void |
destroyView() |
void |
enableContinuouslyRefresh(boolean enable,
int frameRate)
打开/关闭地图持续刷新功能
|
void |
enableDoubleOperation(boolean enable)
设施是否启用双指操作,默认为启用
|
void |
enableRefresh(boolean enable)
允许/屏蔽地图刷新
|
void |
enableShowBuiltInControl(boolean enable)
是否显示内置的控件,内置的控件包括:放大缩小、指南针、比例尺三类。
|
void |
enableSmallViewRespondEvent(boolean enable)
是否允许小地图窗口响应事件,如果允许,那么操作小地图区域时,将近有小地图区域有响应,被覆盖的大地图将不做响应
如果当前小地图已经被隐藏那么不会再接受事件响应 |
void |
enableZOrderOnTop()
设置地图位于最上层
注:此方法必须在子类的构造方法中调用,且必须在子类继承父类的构造方法之后调用
|
CompassView |
getCompassView()
获取指南针控件
|
int |
getFrameRateLimit()
获取地图显示帧率上限
|
MapRenderer |
getMapRenderer()
获取此地图实例所使用的MapRenderer实例对象
如果需要操纵地图,必须使用此方法获取的MapRenderer对象才能有效 |
ScaleView |
getScaleView()
获取比例尺控件
|
MapRenderer |
getSmallMapRenderer()
获取小地图的
MapRenderer 实例对象 |
android.graphics.Rect |
getSmallViewport()
获取小地图矩形区域
|
android.graphics.Rect |
getViewRect()
获取当前视图在屏幕中的绝对包络盒坐标
|
ZoomView |
getZoomView()
获取缩放控件
|
boolean |
isDoubleOperationEnable()
获取是否启用双指操作
|
void |
onAnnotationClicked(Annotation annot,
int area)
点击
Annotation 时触发的回调此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中,在点击Annotation 或其弹出气泡时被调用 |
void |
onAnnotationDeselected(Annotation annot)
当
Annotation 未被选中时触发的回调
此回调实际上运行于MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onAnnotationsClicked(Annotation[] annots)
点击到一个或多个
Annotation ,在onAnnotationClicked(Annotation, int)
中触发,若子类重写了此方法 ,需要调用父类的super.onAnnotationClicked。 |
void |
onAnnotationSelected(Annotation annot)
当
Annotation 被选中时触发的回调此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中,当Annotation 的图标被点击,但它的弹出气泡没有想显示的情况下出发此回调。 |
void |
onCameraAnimationEnded()
摄像机变换动画结束后的回调函数
|
void |
onCameraChanged(int changeType)
相机状态发生改变时触发的回调
|
void |
onDestroy()
销毁
MapView 控件,应该在销毁主Activity时调用 |
void |
onDoubleClick(android.graphics.Point clickPoint)
双击地图时回调,如果双击到
Annotation 或POI时不会回调 |
void |
onDrawFrame(javax.microedition.khronos.opengles.GL10 gl) |
void |
onFocusChanged(int prevFocusedType,
int curFocusedType)
新的
Annotation ,Overlay 和POI被选中成为焦点时被触发 |
void |
onGestureAnimationEvent(boolean animStarted)
手势动画开始和结束时的回调
|
void |
onLayerTilesLoaded(int[] layerTypes)
在新的镜头视角下,至少一块地图分块数据加载完毕时触发,如,基础地图数据和TMC底图数据
此方法是在 MapRenderer.draw() 中调用的,所以是在绘图线程中被调用 |
void |
onLayerTilesReadyForDraw(int[] layerTypes)
监测状态中
MapRenderer.monitorDataReadiness()
,当前比例尺下所有格子的某一图层数据准备好时触发,所有图层数据准备好时结束。 |
void |
onLongPressDown(android.graphics.Point pressedPoint)
长按地图返回长按地点的经纬度坐标,如果长按的是
Annotation 这样的特殊图层,是不会回调此方法的。 |
void |
onLongPressDown(android.graphics.Point pressedPoint,
boolean pressOnAnnotation)
长按地图返回长按地点的经纬度坐标
|
void |
onLongPressUp(android.graphics.Point pressedPoint)
长按抬起的回调,触发长按
onLongPressDown(Point) 回调后,在抬起时会触发此回调 |
void |
onLongPressUp(android.graphics.Point pressedPoint,
boolean pressOnAnnotation)
长按抬起的回调,触发长按
onLongPressDown(Point, boolean) 回调后,在抬起时会触发此回调 |
void |
onNeedsDisplay()
刷新回调,每次刷新时都会回调此函数
无特殊情况,不应在此函数中添加处理逻辑,会影响刷新速度 |
void |
onOnlineDataVersionChecked(boolean upgraded)
在线地图数据版本升级检测回调
|
void |
onOverlayClicked(Overlay overlay,
int area)
|
void |
onOverlayDeselected(Overlay overlay)
|
void |
onOverlaySelected(Overlay overlay,
android.graphics.Point grabbedPoint)
|
void |
onOverlaySelectedNds(Overlay overlay,
NdsPoint grabbedNdsPoint)
|
void |
onPause()
暂停绘图线程,必须在Activity的onPause中调用。
|
void |
onPoiClicked(java.lang.String name,
android.graphics.Point pos)
点击POI时触发的回调
此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onPoiDeselected(java.lang.String name,
android.graphics.Point pos)
反选POI时触发的回调
此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onPoiDeselectedNds(java.lang.String name,
NdsPoint ndsPos)
反选POI时触发的回调
此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onPoiSelected(java.lang.String name,
android.graphics.Point pos)
选中POI时触发的回调
此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onPoiSelectedNds(java.lang.String name,
NdsPoint ndsPos)
选中POI时触发的回调
此回调实际上运行于 MapRenderer.onTouchUp(int, int[], int[], int[]) 方法中 |
void |
onResume()
恢复绘图线程,必须在Activity的onResume中调用。
|
void |
onScrollFinished(boolean isScroll)
拖动或甩动地图结束时的回调,单指或多指操作都可能触发
|
void |
onScrollStarted()
拖动或甩动开始时的回调,单指或多指操作都可能触发
|
void |
onSingleClick(android.graphics.Point clickPoint,
boolean isClickOnSpace)
单击回调
|
void |
onSingleClickNds(NdsPoint clickPoint,
boolean isClickOnSpace)
单击回调
|
void |
onSmallViewCameraChanged(int changeType)
小地图摄像机改变时的回调
|
void |
onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl,
int width,
int height) |
void |
onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl,
javax.microedition.khronos.egl.EGLConfig config) |
void |
onTileLoadingFinished()
地图分块数据加载完毕时触发,如,基础地图数据和TMC底图数据
此方法是在 MapRenderer.draw() 中调用的,所以是在绘图线程中被调用 |
boolean |
onTouch(android.view.View v,
android.view.MotionEvent event) |
void |
onUserRasterDataUpdated(int fromSource)
用户栅格数据更新,调用
MapRenderer#setDataPreference(int) 和MapRenderer#setDataUrlPrefix(int, String)
时触发,说明读取栅格数据时的数据来源 |
void |
removeOnDrawListener(MapView.OnDrawListener listener)
删除绘制监听
|
android.graphics.Bitmap |
screenShot()
全屏截图
|
android.graphics.Bitmap |
screenShotInRenderThread()
在绘图线程中截图,须在
onDrawFrame(GL10) 后调用 |
void |
setClipRect(android.graphics.Rect clipRect)
设置裁剪区域(相对于屏幕),只在设置的区域内绘制地图
|
void |
setCompassView(CompassView view)
设置指南针控件,会替换已存在的指南针控件对象
|
void |
setFrameRateLimit(int refreshRate)
设置地图显示帧率上限
|
void |
setScaleView(ScaleView view)
设置比例尺控件,会替换已存在的比例尺控件对象
|
void |
setSmallViewport(android.graphics.Rect viewport)
设置小地图
MapRenderer 显示窗口大小和位置 |
void |
setSmallViewVisiable(boolean enable)
设置当前的小地图区域是否可见
|
void |
setVisibility(int visibility) |
void |
setZoomView(ZoomView view)
设置缩放控件,会替换已存在的缩放控件对象
|
void |
setZOrderMediaOverlay(boolean i) |
void |
setZOrderOnTop(boolean i) |
void |
surfaceChanged(android.view.SurfaceHolder holder,
int format,
int w,
int h) |
addChildrenForAccessibility, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchSetActivated, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, endViewTransition, findFocus, findViewsWithText, focusableViewAvailable, focusSearch, 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, 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, shouldDelayChildPressedState, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayout
addExtraDataToAccessibilityNodeInfo, addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, autofill, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeScroll, computeSystemWindowInsets, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getApplicationWindowToken, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getId, getImportantForAccessibility, getImportantForAutofill, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTouchables, getTouchDelegate, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, offsetLeftAndRight, offsetTopAndBottom, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onCreateInputConnection, onDragEvent, onDrawForeground, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideStructure, onProvideVirtualStructure, onRtlPropertiesChanged, onScreenStateChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestFitSystemWindows, requestLayout
public MapView(android.content.Context context)
context
- 主视图的Activity实例public MapView(android.content.Context context, android.util.AttributeSet attrs)
context
- 主视图的Activity实例attrs
- 视图属性public MapView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
context
- 主视图的Activity实例attrs
- 视图属性defStyle
- 默认样式public MapView(android.content.Context context, boolean useSmallMapView, android.graphics.Rect smallViewPort)
context
- 主视图的Activity实例useSmallMapView
- 是否打开小地图smallViewPort
- 小地图窗口位置public MapView(android.content.Context context, boolean useSmallMapView, android.graphics.Rect smallViewPort, boolean useBuilitInControl)
context
- 主视图的Activity实例useSmallMapView
- 是否打开小地图smallViewPort
- 小地图窗口位置useBuilitInControl
- 是否使用内置的指南针、缩放控件public void destroyMapRenderer()
public final void destroyView()
public final MapRenderer getMapRenderer()
onSurfaceCreated(GL10, EGLConfig)
已经执行完成,否则获取出来的结果可能是null,如果SDK没有地图包授权,也将返回null。 public final MapRenderer getSmallMapRenderer()
MapRenderer
实例对象onSurfaceCreated(GL10, EGLConfig)
已经执行完成,否则获取出来的结果可能是null,如果SDK没有地图包授权,也将返回null。public final void enableSmallViewRespondEvent(boolean enable)
enable
- public final android.graphics.Rect getViewRect()
public void setSmallViewVisiable(boolean enable)
enable
- true表示可见,false表示不可见public void setSmallViewport(android.graphics.Rect viewport)
MapRenderer
显示窗口大小和位置viewport
- 小地图区域窗口矩形onSurfaceCreated(GL10, EGLConfig)
、
onSurfaceChanged(GL10, int, int)
和
onDrawFrame(GL10)
这三个方法中使用 public android.graphics.Rect getSmallViewport()
public void onNeedsDisplay()
MapRenderer.Listener
onNeedsDisplay
在接口中 MapRenderer.Listener
public void onAnnotationClicked(Annotation annot, int area)
MapRenderer.Listener
Annotation
时触发的回调MapRenderer.onTouchUp(int, int[], int[], int[])
方法中,在点击Annotation
或其弹出气泡时被调用onAnnotationClicked
在接口中 MapRenderer.Listener
annot
- 被点击的Annotation
area
- 被点击的区域Annotation.Area
,如果area为Annotation.Area.icon
,表示点击的是Annotation
的图标本身Annotation
,
Annotation.Area
public void onAnnotationsClicked(Annotation[] annots)
Annotation
,在onAnnotationClicked(Annotation, int)
中触发,若子类重写了此方法 ,需要调用父类的super.onAnnotationClicked。 Annotation
应该在收到 onAnnotationClicked(Annotation, int)
或
onAnnotationDeselected(Annotation)
后去掉选中状态annots
- 点击到Annotation
onAnnotationClicked(Annotation, int)
public void onAnnotationSelected(Annotation annot)
MapRenderer.Listener
Annotation
被选中时触发的回调MapRenderer.onTouchUp(int, int[], int[], int[])
方法中,当Annotation
的图标被点击,但它的弹出气泡没有想显示的情况下出发此回调。onAnnotationSelected
在接口中 MapRenderer.Listener
annot
- 当前被选中的Annotation
Annotation
public void onAnnotationDeselected(Annotation annot)
MapRenderer.Listener
Annotation
未被选中时触发的回调
此回调实际上运行于MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onAnnotationDeselected
在接口中 MapRenderer.Listener
annot
- 当前取消选中状态的Annotation
Annotation
public void onFocusChanged(int prevFocusedType, int curFocusedType)
MapRenderer.Listener
Annotation
,Overlay
和POI被选中成为焦点时被触发onFocusChanged
在接口中 MapRenderer.Listener
prevFocusedType
- 前一个焦点的类型 MapRenderer.FocusedObjType
curFocusedType
- 当前焦点类型MapRenderer.FocusedObjType
,前后焦点所在的poi,
annotation和overlay可以通过onxxSelected和onxxDeselected获取public void onOverlayClicked(Overlay overlay, int area)
MapRenderer.Listener
onOverlayClicked
在接口中 MapRenderer.Listener
overlay
- 被点击的Overlay
area
- 被点击的区域Annotation.Area
,如果回调的area为Annotation.Area.icon
,表示点击的是Overlay
本身Overlay
,
Annotation.Area
public void onOverlaySelected(Overlay overlay, android.graphics.Point grabbedPoint)
MapRenderer.Listener
onOverlaySelected
在接口中 MapRenderer.Listener
overlay
- 被点击的Overlay
grabbedPoint
- 距离点击点最近的有效点坐标,通常情况下,这个点就是点击点本身,但是对于PolylineOverlay
或者RouteOverlay
可能不是点击点public void onOverlayDeselected(Overlay overlay)
MapRenderer.Listener
onOverlayDeselected
在接口中 MapRenderer.Listener
overlay
- 触发事件的Overlay
public void onOverlaySelectedNds(Overlay overlay, NdsPoint grabbedNdsPoint)
MapRenderer.Listener
onOverlaySelectedNds
在接口中 MapRenderer.Listener
overlay
- 被点击的Overlay
grabbedNdsPoint
- 距离点击点最近的有效Nds坐标,通常情况下,这个点就是点击点本身,但是对于PolylineOverlay
或者RouteOverlay
可能不是点击点public void onPoiSelected(java.lang.String name, android.graphics.Point pos)
MapRenderer.Listener
MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onPoiSelected
在接口中 MapRenderer.Listener
name
- POI名称pos
- POI所在位置经纬度坐标public void onPoiDeselected(java.lang.String name, android.graphics.Point pos)
MapRenderer.Listener
MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onPoiDeselected
在接口中 MapRenderer.Listener
name
- POI名称pos
- POI所在位置经纬度坐标值public void onPoiSelectedNds(java.lang.String name, NdsPoint ndsPos)
MapRenderer.Listener
MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onPoiSelectedNds
在接口中 MapRenderer.Listener
name
- POI名称ndsPos
- POI所在的NDS坐标public void onPoiDeselectedNds(java.lang.String name, NdsPoint ndsPos)
MapRenderer.Listener
MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onPoiDeselectedNds
在接口中 MapRenderer.Listener
name
- POI名称ndsPos
- POI所在位置的NDS坐标值public void onPoiClicked(java.lang.String name, android.graphics.Point pos)
MapRenderer.Listener
MapRenderer.onTouchUp(int, int[], int[], int[])
方法中onPoiClicked
在接口中 MapRenderer.Listener
name
- POI名称pos
- POI所在位置的坐标public void onCameraChanged(int changeType)
MapRenderer.Listener
onCameraChanged
在接口中 MapRenderer.Listener
changeType
- 相机参数改变类型MapRenderer.CameraSetting
MapRenderer.CameraSetting
public void onCameraAnimationEnded()
MapRenderer.Listener
onCameraAnimationEnded
在接口中 MapRenderer.Listener
public void onGestureAnimationEvent(boolean animStarted)
MapRenderer.Listener
onGestureAnimationEvent
在接口中 MapRenderer.Listener
animStarted
- 动画开始时为true,结束时为falsepublic void onTileLoadingFinished()
MapRenderer.Listener
MapRenderer.draw()
中调用的,所以是在绘图线程中被调用onTileLoadingFinished
在接口中 MapRenderer.Listener
public void onLayerTilesLoaded(int[] layerTypes)
MapRenderer.Listener
MapRenderer.draw()
中调用的,所以是在绘图线程中被调用onLayerTilesLoaded
在接口中 MapRenderer.Listener
layerTypes
- 已经加载完成的图层瓦片对象 count,加载完成的图层瓦片数量public void onLayerTilesReadyForDraw(int[] layerTypes)
MapRenderer.Listener
MapRenderer.monitorDataReadiness()
,当前比例尺下所有格子的某一图层数据准备好时触发,所有图层数据准备好时结束。onLayerTilesReadyForDraw
在接口中 MapRenderer.Listener
layerTypes
- 数据准备好的图层LayerType
public void onOnlineDataVersionChecked(boolean upgraded)
MapRenderer.Listener
onOnlineDataVersionChecked
在接口中 MapRenderer.Listener
upgraded
- 是否升级,如果升级则返回true,否则返回falsepublic void onUserRasterDataUpdated(int fromSource)
MapRenderer.Listener
MapRenderer#setDataPreference(int)
和MapRenderer#setDataUrlPrefix(int, String)
时触发,说明读取栅格数据时的数据来源onUserRasterDataUpdated
在接口中 MapRenderer.Listener
fromSource
- 数据来源DataPreference
public void onScrollFinished(boolean isScroll)
isScroll
- true时为拖动回调,false时为甩动回调public void onScrollStarted()
public void onSmallViewCameraChanged(int changeType)
changeType
- 摄像机参数改变类型MapRenderer.CameraSetting
MapRenderer.CameraSetting
public void surfaceChanged(android.view.SurfaceHolder holder, int format, int w, int h)
public void setZOrderOnTop(boolean i)
public void setZOrderMediaOverlay(boolean i)
public void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl)
onDrawFrame
在接口中 android.opengl.GLSurfaceView.Renderer
public void onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl, int width, int height)
onSurfaceChanged
在接口中 android.opengl.GLSurfaceView.Renderer
public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl, javax.microedition.khronos.egl.EGLConfig config)
onSurfaceCreated
在接口中 android.opengl.GLSurfaceView.Renderer
public void onPause()
MapView
,必须在切换到其他
MapView
时调用此方法暂停绘图线程,否则可能出现花屏、白屏、黑屏等问题。
常见的应用场景是,ViewPager的不同page中显示多个地图,在切换走当前page的地图时需要调用此方法GLSurfaceView.onPause()
onResume()
配对使用public void onResume()
MapView
,必须在切换回当前
MapView
时调用此方法恢复绘图线程。
常见的应用场景是,ViewPager的不同page中显示多个地图,在切换回当前page的地图时需要调用此方法GLSurfaceView.onResume()
onPause()
配对使用public void onDestroy()
MapView
控件,应该在销毁主Activity时调用public boolean onTouch(android.view.View v, android.view.MotionEvent event)
onTouch
在接口中 android.view.View.OnTouchListener
public void onLongPressUp(android.graphics.Point pressedPoint)
onLongPressDown(Point)
回调后,在抬起时会触发此回调pressedPoint
- 长按的点坐标onLongPressUp(Point, boolean)
public void onLongPressUp(android.graphics.Point pressedPoint, boolean pressOnAnnotation)
onLongPressDown(Point, boolean)
回调后,在抬起时会触发此回调pressedPoint
- 长按的点坐标onLongPressUp(Point)
public void onLongPressDown(android.graphics.Point pressedPoint)
Annotation
这样的特殊图层,是不会回调此方法的。
和onLongPressUp(Point)
成对。pressedPoint
- 长按点的经纬度坐标onLongPressDown(Point, boolean)
public void onLongPressDown(android.graphics.Point pressedPoint, boolean pressOnAnnotation)
pressedPoint
- 长按点的经纬度坐标pressOnAnnotation
- 是否按到Annotation
这样的特殊图层onLongPressDown(Point)
public void onDoubleClick(android.graphics.Point clickPoint)
Annotation
或POI时不会回调clickPoint
- 双击的点public void onSingleClick(android.graphics.Point clickPoint, boolean isClickOnSpace)
clickPoint
- 单击点的世界坐标isClickOnSpace
- 是否点击到空白处,非空白处是指其他事件相应的部分,比如点击到POI或Annotation
,其余不能相应特殊事件的部分都为空白处public void onSingleClickNds(NdsPoint clickPoint, boolean isClickOnSpace)
clickPoint
- 单击点的NDS坐标isClickOnSpace
- 是否点击到空白处,非空白处是指其他事件相应的部分,比如点击到POI或Annotation
,其余不能相应特殊事件的部分都为空白处public void enableRefresh(boolean enable)
enable
- false时屏蔽掉地图绘制事件,即不响应onNeedsDisplay()
public void enableShowBuiltInControl(boolean enable)
enable
- 为true时显示内置的控件,false时不显示public ZoomView getZoomView()
ZoomView
, 未开启时返回nullsetZoomView(ZoomView)
public void setZoomView(ZoomView view)
view
- 缩放控件ZoomView
getZoomView()
public CompassView getCompassView()
CompassView
, 未开启时返回nullsetCompassView(CompassView)
public void setCompassView(CompassView view)
view
- 指南针控件CompassView
getCompassView()
public ScaleView getScaleView()
ScaleView
, 未开启时返回nullsetScaleView(ScaleView)
public void setScaleView(ScaleView view)
view
- 比例尺控件ScaleView
getScaleView()
public android.graphics.Bitmap screenShot()
Bitmap
可能为同一个对象public android.graphics.Bitmap screenShotInRenderThread()
onDrawFrame(GL10)
后调用public void setVisibility(int visibility)
setVisibility
在类中 android.view.View
public void enableDoubleOperation(boolean enable)
enable
- 是否启用双指操作,true:启用双指操作,false:禁用双指操作public boolean isDoubleOperationEnable()
public void setClipRect(android.graphics.Rect clipRect)
clipRect
- 裁剪区域(相对于屏幕)public void addOnDrawListener(MapView.OnDrawListener listener)
listener
- MapView.OnDrawListener
public void removeOnDrawListener(MapView.OnDrawListener listener)
listener
- MapView.OnDrawListener
public void enableZOrderOnTop()
public void setFrameRateLimit(int refreshRate)
refreshRate
- 地图显示帧率上限public int getFrameRateLimit()
public void enableContinuouslyRefresh(boolean enable, int frameRate)
enable
- 是否打开frameRate
- 地图刷新帧率©Mapbar Engine Team;All Rights Reserved