在Android缩小时Skobbler注释从地图上消失 [英] Skobbler Annotation disappears from map when zooming out on Android

查看:225
本文介绍了在Android缩小时Skobbler注释从地图上消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我添加注释的名单与code类似于下面的一个图形页面:

Currently, I am adding a list of annotations to a mapview with code similar to the following:

// Add to map view
SKAnnotation annotation = new SKAnnotation(i++);
annotation.getLocation().setLongitude(result.longitude);
annotation.getLocation().setLatitude(result.latitude);
annotation.setMininumZoomLevel(1);
annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_POP_OUT);

然而,每当我在地图上查看注释,它们就会消失后,我在缩放级别4.0缩小到任何东西。综观文档的<一个href=\"http://developer.skobbler.com/docs/android/2.5.0/com/skobbler/ngx/map/SKAnnotation.html#setMininumZoomLevel(int)\"相对=nofollow>标注类(以及在code确认),我看到默认缩放级别设置为4,但似乎我的呼吁 .setMinimumZoomLevel 将被忽略。

Yet whenever I view the annotations on the map, they disappear after I zoom out to anything under zoom level 4.0. Looking at the docs for the Annotation class (as well as confirming in the code), I see that the default zoom level is set to 4, yet it seems that my call to .setMinimumZoomLevel is ignored.

没有人有任何深入了解正在发生什么,或者这可能是在SDK中一个已知的bug?

Does anyone have any insight into what is happening or if this might be a known bug within the SDK?

我使用Skobbler 2.5在Android上。

I'm using Skobbler 2.5 on Android.

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

Thanks for any help in the matter!

推荐答案

根据关上原来的问题安藤的评论和引用文档的这里,我更新了code使用他介绍的解决办法,使批注向下显示缩放比2平。

Based off Ando's comment on the original question and referencing the documentation here, I updated the code to use the workaround he described to allow annotations to show up down to zoom level 2.

原来的code:

SKAnnotation annotation = new SKAnnotation(i++);
annotation.getLocation().setLongitude(result.longitude);
annotation.getLocation().setLatitude(result.latitude);
annotation.setMininumZoomLevel(1); // Note: this does not work
annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_POP_OUT);

更新code:

SKAnnotation annotation = new SKAnnotation(i++);
annotation.getLocation().setLongitude(result.longitude);
annotation.getLocation().setLatitude(result.latitude);
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);

一对夫妇的注意事项:

A couple things to note:


  1. <击> .setImagePath() 和<击> .setImageSize() 在最新的SDK都失precated方法,即使它们在文档中仍引用上面。不知道这意味着还有另外一种选择,以通过绝对路径的方式显示图像,或如果他们只是逐步取消这个功能了。

  2. 在我的特殊的例子,我们使用的是紫色的脚,以显示注解,但该引脚的绝对路径文件名其实叫做 icon_greypin 。它看起来像其它引脚图像文件名进行适当不过的名字命名。

  1. .setImagePath() and .setImageSize() are both deprecated methods in the latest SDK even though they're still referenced in the documentation above. Not sure if that means there is another alternative to displaying images via an absolute path approach, or if they're simply phasing this functionality out.
  2. In my particular example, we're using the purple pin to display annotations, but the absolute path file name for that pin is actually called icon_greypin. It looks like the other pin image file name are named appropriately however.

不管怎么说,这个曾作为解决我的具体问题,直到SDK更新,所以我将其标记为答案,我希望它可以帮助别人!由于安藤在正确方向的一步!

Anyways, this served as a solution for my particular problem until the SDK is updated, so I'm marking it as the answer and I hope it helps someone else! Thanks to Ando for the step in the right direction!

这篇关于在Android缩小时Skobbler注释从地图上消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆