我创建了一个演示应用程序来了解 SKMaps,它在添加注释方面效果很好。但是,现在我已将代码移至具有相同要求的实际项目中。添加的注释未显示。我尝试使用 SKAnnotationView(自定义 View )和默认注释类型,如 SKAnnotation.SK_ANNOTATION_TYPE_RED 和 SKAnnotation.SK_ANNOTATION_TYPE_PURPLE。未向 map 添加任何内容。
我在同一屏幕上有一个自定义 View 寻呼机,我删除了它并检查仍然没有用。 SKMapViewHolder 是动态添加的。
动态添加SKMapViewHolder的代码 fragment :
SKMapViewHolder mMapHolder = new SKMapViewHolder(OfflineMapScreen.this);
mMapHolder.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
RelativeLayout outerLayout = (RelativeLayout) findViewById(R.id.outer_layout);
outerLayout.addView(mMapHolder);
RelativeLayout.LayoutParams rlp = (android.widget.RelativeLayout.LayoutParams) mMapHolder.getLayoutParams();
rlp.addRule(RelativeLayout.BELOW, R.id.header);
mMapHolder.setLayoutParams(rlp);
mOSMMapView = mMapHolder.getMapSurfaceView();
mOSMMapView.setMapSurfaceListener(this);
mOSMMapView.getMapSettings().setFollowerMode(SKMapFollowerMode.NONE);
mOSMMapView.getMapSettings().setMapPanningEnabled(true);
mOSMMapView.getMapSettings().setInertiaPanningEnabled(true);
mOSMMapView.getMapSettings().setCompassShown(false);
mOSMMapView.getMapSettings().setCurrentPositionShown(false);
mOSMMapView.setZoomSmooth(14f, 500);
有人有解决办法吗?添加注释的代码 fragment 可以在这里看到:http://postimg.org/image/sdbwzej9z/
最佳答案
在您提供的图像中,我们注意到在设置位置时,您对纬度和经度重复使用了相同的值。使用类似的东西:
annotationDrawable.setLocation(new SKCoordinate(Double.valueOf(aPlace.getLongitude()),Double.valueOf(aPlace.getLatitude())) ;
关于android - Android 中的 SKMaps 不显示注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27229459/