我有一个SKMapSurfaceView
我已经设置了一个监听器(通过setMapSurfaceListener
,传入一个SKMapSurfaceListener
对象)。当我点击添加到SKMapSurfaceView
via的注释时addAnnotation
,侦听器会收到一个onSingleTap
事件,但不会onAnnotationSelected
。我在 Skobbler 的日志中看到它检测到对“自定义 POI”的点击,我认为这是我的注释(尤其是因为该自定义 POI 在他们的日志中的 ID 是我为注释提供的唯一 ID)。但是,我的听众都没有onAnnotationSelected
,也没有onCustomPOISelected
被调用。为什么?
编辑:这是我的代码:
SKAnnotation annotation = new SKAnnotation();
annotation.setUniqueID(123456);
annotation.setLocation(new SKCoordinate(
13.45457,
52.51592));
annotation.setMininumZoomLevel(15);
annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_MARKER);
mapView.addAnnotation(annotation);
mapView.setMapSurfaceListener(new SKMapSurfaceListener() {
@Override
public void onSurfaceCreated() {
}
@Override
public void onSingleTap(SKScreenPoint arg0) {
Log.d("onSingleTap");
}
@Override
public void onScreenOrientationChanged() {
}
@Override
public void onRotateMap() {
}
@Override
public void onPOIClusterSelected(SKPOICluster arg0) {
Log.d("onPOIClusterSelected");
}
@Override
public void onMapRegionChanged(SKCoordinate arg0) {
}
@Override
public void onMapPOISelected(SKMapPOI arg0) {
Log.d("onMapPOISelected");
}
@Override
public void onMapActionUp(SKScreenPoint arg0) {
}
@Override
public void onMapActionDown(SKScreenPoint arg0) {
}
@Override
public void onLongPress(SKScreenPoint arg0) {
}
@Override
public void onInternetConnectionNeeded() {
}
@Override
public void onInternationalisationCalled(int arg0) {
}
@Override
public void onDoubleTap(SKScreenPoint arg0) {
Log.d("onDoubleTap");
float zoom = mapView.getZoomLevel() + 1;
if (zoom <= SKMapSurfaceView.MINIMUM_ZOOM_LEVEL) {
mapView.setZoomSmooth(zoom, 250);
}
}
@Override
public void onCustomPOISelected(SKMapCustomPOI arg0) {
Log.d("onCustomPOISelected");
}
@Override
public void onCompassSelected() {
}
@Override
public void onAnnotationSelected(SKAnnotation annotation) {
Log.d("onAnnotationSelected");
}
@Override
public void onAnimationsFinished() {
}
@Override
public void onActionZoom() {
Log.d("onActionZoom");
}
@Override
public void onActionPan() {
Log.d("onActionPan");
}
});
然后如果我在注释上的某个地方点击一下,然后在注释上点击一下,我会得到日志:
06-22 19:34:27.674: D/SKMaps(20852): MapRenderer----onSurfaceCreated
06-22 19:34:27.679: D/SKMaps(20852): MapRenderer---- LinInitialized = true
06-22 19:34:28.394: D/SKMaps(20852): MapRenderer----Map follower mode 0
06-22 19:34:28.394: D/SKMaps(20852): MapRenderer----onSurfaceChanged width = 1080 height= 1701
...
06-22 19:35:11.729: D/SKMaps(20852): SKMapSurfaceView----SINGLE TAP CONFIRMED 0
06-22 19:35:11.729: D/SKMaps(20852): SKMapSurfaceView----Check north indicator 4 526.0 705.0 296 64 0 64
06-22 19:35:11.729: D/SKMaps(20852): SKMapSurfaceView----notifyWithMapInfo
06-22 19:35:11.759: D/Wanderant(20852): onSingleTap
06-22 19:35:17.399: D/SKMaps(20852): SKMapSurfaceView----SINGLE TAP CONFIRMED 0
06-22 19:35:17.399: D/SKMaps(20852): SKMapSurfaceView----Check north indicator 4 532.0 720.0 296 64 0 64
06-22 19:35:17.399: D/SKMaps(20852): SKMapSurfaceView----notifyWithMapInfo
06-22 19:35:17.429: D/SKMaps(20852): SKMapSurfaceView---- Tapped custom POI id=123456
06-22 19:35:17.429: D/Wanderant(20852): onSingleTap
如您所见,在这两种情况下,我都会收到 onSingleTap 回调。(我跳过了 Skobbler 地图初始化代码,但它是按照教程完成的,它确实初始化成功并显示了地图等)