Results 1 to 10 of 13

Thread: SKMapsAndroid 2.5.1: updateAnnotation ignores location update when using annotationVi

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Neuer skobbler
    Join Date
    20.10.2015
    Posts
    7

    SKMapsAndroid 2.5.1: updateAnnotation ignores location update when using annotationVi

    I am using SKMaps 2.5.1 on Android and have a usecase where I show about 10-20 icons on a map which represent moving objects in the vicinity of the user. Locations are updated about 10x per second for each of these.

    I can create annotations with an annotation type, for instance SK_ANNOTATION_TYPE_RED, add them to the map using addAnnotation; then when a location update comes in I update the existing annotation object and call updateAnnotation and see my annotations moving around.

    Now I want to use custom icons so I've created a layout and inflate it, then assign it to an annotationView. However, when I do this, the updateAnnotation call no longer updates the location of the icons on the map.

    To create the annotation, I use the following code:

    Code:
    final SKAnnotation annotation = new SKAnnotation(mi.getId());
    annotation.setLocation(new SKCoordinate(mi.getLon(), mi.getLat()));
    annotation.setMininumZoomLevel(0);
    
    final SKAnnotationView annotationView = new SKAnnotationView();
    View customView =(RelativeLayout) ((LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
            R.layout.map_item, null, false);
    final ImageView img = (ImageView) customView.findViewById(R.id.img);
    
    img.setImageResource(R.drawable.some_image);
    annotationView.setView(customView);
    annotation.setAnnotationView(annotationView);
    
    mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_NONE);
    My mapitem layout is:
    HTML Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="32dp"
        android:layout_height="32dp">
        <ImageView
            android:id="@+id/img"
            android:layout_width="32dp"
            android:layout_height="32dp" />
    </RelativeLayout>
    To update an annotation location, I use the following code:
    Code:
    final SKAnnotation annotation = mAnnotationForMapItemId.get(mi.getId());
    
    annotation.setLocation(new SKCoordinate(mi.getLon(), mi.getLat()));
    mapView.updateAnnotation(annotation);
    I can see the icons appear on the map correctly, in the locations where I expect them, but their location updates are being ignored. Am I forgetting something that is specific to annotations with custom views or is this a bug?

    If anybody could advise, I would be grateful.


    Gerard
    Last edited by aridane; 22.10.2015 at 13:28.

Posting Permissions

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