Results 1 to 5 of 5

Thread: Annotation Combining

  1. #1
    Etablierter skobbler
    Join Date
    11.04.2015
    Posts
    41

    Annotation Combining

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

    Code:
        
    public Runnable updateAnnotationTask = new Runnable() {
    
            @Override
            public void run() {
                android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
    
                operationFinished=false;
    
                allVisibleAnnotations = new ArrayList();
    
                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().getLongitude() + annotation2.getLocation().getLongitude()) / 2,
                                    (annotation2.getLocation().getLatitude() + annotation2.getLocation().getLatitude()) / 2));
                            SKAnnotationView annotationView = new SKAnnotationView();
    
                            annotationView.setView(circleView);
                            annotationDrawable.setAnnotationView(annotationView);
    
                            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
    Last edited by mz87; 04.11.2015 at 15:04.

  2. #2
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    Check the SKPOICluster class: http://developer.skobbler.ro/docs/an...OICluster.html -that would help you to get a better look on the map for all your 1000 annotations

  3. #3
    Etablierter skobbler
    Join Date
    11.04.2015
    Posts
    41
    Thanks for your reply. So it means that I have to use SKMapCustomPOI instead of Annotations to use this ?

  4. #4
    Etablierter skobbler
    Join Date
    11.04.2015
    Posts
    41
    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

  5. #5
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •