在 Android SDK 2.5 上尝试使用 SKAnnotations(紫色针标记类型)查看地图时偶尔会看到黑色矩形覆盖 SKMap

Occasionally see black rectangles overlaying SKMap when attempting to view map with SKAnnotations (purple pin marker type) on Android SDK 2.5

我们目前正在使用 Skobbler 2.5 构建 Android 导航应用程序。应用程序中的一个功能允许您沿着先前计算的路线放置注释。当 SKMap 在屏幕上可见或在背景中时,可以将注释放置在地图上。

我们注意到,偶尔在地图当前不可见时添加注释,然后继续并使地图可见会导致黑色矩形出现在已添加注释的位置。

注释本身是使用已弃用的 .setImagePath() 方法添加的,但这是由于设置了一种变通方法,以便在将地图缩小到小于 4 的缩放级别时使注释可见。

这是当前如何添加注释的示例:

SKAnnotation annotation = new SKAnnotation(i++);
annotation.getLocation().setLongitude(result.longitude);
annotation.getLocation().setLatitude(result.latitude);
// annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);
annotation.setMininumZoomLevel(2);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (metrics.densityDpi < DisplayMetrics.DENSITY_HIGH) {
    annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().
            getMapResourcesPath() + "/.Common/icon_greypin@2x.png");
    // set the size of the image in pixel
    annotation.setImageSize(128);
} else {
    annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().
            getMapResourcesPath() + "/.Common/icon_greypin@3x.png");
    // set the size of the image in pixels
    annotation.setImageSize(256);
}
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_POP_OUT);

但由于某些原因,地图偶尔会出现这样的情况:

通常,它应该看起来更像这样:

有没有人对这个问题有任何经验并且知道正确处理它的方法?或者我可能需要注意某种竞争条件?

感谢您对此事的任何帮助! 基思

我必须查看您的所有项目以获得详细答案。没有:

  • 当地图不可见时不要添加 annotations/visual 元素,而是在 "buffer" 中设置更改并在恢复地图时执行更改
  • imagePath API 已弃用,在下一次更新中我们将完全删除它。自定义视图 API 提供更多控制并且更具可扩展性,因此我们将只支持 API。您可以尝试将所有注释切换为使用自定义视图,看看问题是否仍然重现
  • 您是否在您的应用中使用多个地图视图?如果是,请参阅:http://developer.skobbler.com/getting-started/android#sec033