目前,我正在向地图视图添加注释列表,代码类似于以下内容:
// 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 以下的任何内容后,它们就会消失。查看文档注解 http://developer.skobbler.com/docs/android/2.5.0/com/skobbler/ngx/map/SKAnnotation.html#setMininumZoomLevel(int)类(以及在代码中确认),我看到默认缩放级别设置为 4,但似乎我的调用.setMinimumZoomLevel
被忽略。
有谁知道正在发生的事情或者这是否可能是 SDK 中的已知错误?
我在 Android 上使用 Skobbler 2.5。
感谢您对此事的任何帮助!
基于安藤对原始问题的评论并参考文档here http://developer.skobbler.com/getting-started/android#sec009,我更新了代码以使用他描述的解决方法,以允许注释向上显示到缩放级别 2。
原始代码:
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);
更新的代码:
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/[email protected] /cdn-cgi/l/email-protection");
// set the size of the image in pixel
annotation.setImageSize(128);
} else {
annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().
getMapResourcesPath()+ "/.Common/[email protected] /cdn-cgi/l/email-protection");
// set the size of the image in pixels
annotation.setImageSize(256);
}
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_POP_OUT);
有几点需要注意:
-
.setImagePath()
罢工>和.setImageSize()
都是最新 SDK 中已弃用的方法,尽管上面的文档中仍然引用了它们。不确定这是否意味着还有另一种选择可以通过绝对路径方法显示图像,或者他们是否只是逐步淘汰此功能。
- 在我的特定示例中,我们使用紫色引脚来显示注释,但该引脚的绝对路径文件名实际上称为
icon_greypin
。不过,其他引脚图像文件名似乎已正确命名。
无论如何,在 SDK 更新之前,这一直是我的特定问题的解决方案,所以我将其标记为答案,希望它对其他人有帮助!感谢安藤朝着正确的方向迈出了一步!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)