Skip to content Skip to sidebar Skip to footer

Skobbler Annotation Disappears From Map When Zooming Out On Android

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.getLoca

Solution 1:

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.

Original code:

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

Updated 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 pixelannotation.setImageSize(128);
} else {
    annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().
            getMapResourcesPath()+ "/.Common/icon_greypin@3x.png");
    // set the size of the image in pixelsannotation.setImageSize(256);
}
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_POP_OUT);

A couple things to note:

  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.

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!

Post a Comment for "Skobbler Annotation Disappears From Map When Zooming Out On Android"