PDA

View Full Version : Annotation Combining



mz87
04.11.2015, 15:01
Hi
I'm having trouble with huge amount of Annotations on the screen.
Is there any mechanism or implementation of merging many Annotations into one (for example, Circle with number inside) ?
I mean, when zoom is not close enough and you see few Annotations laying one over each other, it would be great to see some indication about that, and when user zooms IN, circles disappear and Annotations show up.

Like Tripadvisor, Waze, Google Places etc.

What I did by myself ..



public Runnable updateAnnotationTask = new Runnable() {

@Override
public void run() {
android.os.Process.setThreadPriority(android.os.Pr ocess.THREAD_PRIORITY_BACKGROUND);

operationFinished=false;

allVisibleAnnotations = new ArrayList<SKAnnotation>();

allVisibleAnnotations.addAll(allAnnotations);

for (int i = allVisibleAnnotations.size() - 1; i >= 0; i--) {
SKAnnotation annotation1 = allVisibleAnnotations.get(i);
SKScreenPoint skPoint1 = mapView.coordinateToPoint(annotation1.getLocation( ));

for (int j = i - 1; j >= 0; j--) {
SKAnnotation annotation2 = allVisibleAnnotations.get(j);
SKScreenPoint skPoint2 = mapView.coordinateToPoint(annotation2.getLocation( ));

if (Math.abs(skPoint1.getX() - skPoint2.getX()) < 48 && Math.abs(skPoint1.getY() - skPoint2.getY()) < 48) {
/* now we need to combine them into one object ! J ! and delete one of them | I | */
SKAnnotation annotationDrawable = new SKAnnotation(Constants.COMBINE_INDEX + 1 + j);
annotationDrawable.setLocation(new SKCoordinate((annotation1.getLocation().getLongitu de() + annotation2.getLocation().getLongitude()) / 2,
(annotation2.getLocation().getLatitude() + annotation2.getLocation().getLatitude()) / 2));
SKAnnotationView annotationView = new SKAnnotationView();

annotationView.setView(circleView);
annotationDrawable.setAnnotationView(annotationVie w);

allVisibleAnnotations.remove(i);
allVisibleAnnotations.set(j, annotationDrawable);

j = 0;
}
}
}

mapView.deleteAllAnnotationsAndCustomPOIs();

for (int i = 0; i < allVisibleAnnotations.size(); i++) {
mapView.addAnnotation(allVisibleAnnotations.get(i) , SKAnimationSettings.ANIMATION_NONE);
}

operationFinished=true;
}
};



Everything was working pretty great, but now I have more than 1000 Annotations and it's getting worse :(

Any suggestion or idea how to speed up this thing and avoid lagging would be great! :)

Thanks in advance

Adela_Silvia
05.11.2015, 16:34
Check the SKPOICluster class: http://developer.skobbler.ro/docs/android/2.5.1/com/skobbler/ngx/map/SKPOICluster.html -that would help you to get a better look on the map for all your 1000 annotations

mz87
05.11.2015, 16:40
Thanks for your reply. So it means that I have to use SKMapCustomPOI instead of Annotations to use this ?

mz87
05.11.2015, 21:06
I checked how SKMapCustomPOI works - everything is pretty good, I guess they can totally replace SKAnnotation ..
The problem is design and looks .. is there an "easy" way to customize Custom Point icons, sizes, colors etc?
As far as I understand I have to modify style JSON file, then modify icon assets from SKMaps.zip etc.
I wonder, is there any tool for that?

best regards

Adela_Silvia
06.11.2015, 11:13
Hi mz87,

For the annotation this option is not available, only for custom POIs.
As for creating a custom style we have the StyleEditor tool. Please send an email at dev@telenav.com and we'll provide you the requested information.