2014-12-21 3 views
2

Я использую Skobbler Maps. Когда я устанавливаю свои собственные значки в виде аннотаций, onAnnotationSelected не вызывается. И когда я устанавливаю значки по умолчанию (annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);), он работал правильно. Что я делаю неправильно?Skobbler. onAnnotationSelected not called, когда я устанавливаю свои собственные аннотации

cursor = dataBaseHelper.getWritableDatabase().rawQuery(stringBuilder.toString(), null); 
     int count = cursor.getCount(); 
     for (int i = 0; i < count; i++) { 
      if (cursor.moveToPosition(i)) { 
       SKAnnotation annotation = new SKAnnotation(); 
       annotation.setUniqueID(cursor.getInt(cursor.getColumnIndex(1))); 
       annotation.setLocation(new SKCoordinate(cursor.getDouble(cursor.getColumnIndex(2)), cursor.getDouble(cursor.getColumnIndex(3)))); 
       annotation.setMininumZoomLevel(5); 
       annotation.setImageSize(32); 
       annotation.setImagePath(imagePath+cursor.getString(cursor.getColumnIndex(4))); 
       mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_NONE); 

ответ

2

Вам необходимо установить центральную точку изображения, нажав на аннотацию, будет зависеть от этого значения.

// add an annotation with an image file 
    SKAnnotation annotation = new SKAnnotation(13); 
    annotation.setLocation(new SKCoordinate(-122.434516, 37.770712)); 
    annotation.setMininumZoomLevel(5); 


    DisplayMetrics metrics = new DisplayMetrics(); 
    getWindowManager().getDefaultDisplay().getMetrics(metrics); 
    if (metrics.densityDpi < DisplayMetrics.DENSITY_HIGH) { 
     // set the center point of the image - tapping on an annotation will depend on this value . Also the actual gps coordinates of the annotation will be in the center of the image. 
     annotation.getOffset().setX(16); 
     annotation.getOffset().setY(16); 
     annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().getMapResourcesPath() + "/.Common/poi_marker.png"); 
     // set the size of the image in pixels 
     annotation.setImageSize(32); 
    } else { 
     // set the center point of the image - tapping on an annotation will depend on this value . Also the actual gps coordinates of the annotation will be in the center of the image. 
     annotation.getOffset().setX(32); 
     annotation.getOffset().setY(32); 
     annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().getMapResourcesPath()+ "/.Common/poi_marker_retina.png"); 
     // set the size of the image in pixels 
     annotation.setImageSize(64); 

    } 
    mapView.addAnnotation(annotation,SKAnimationSettings.ANIMATION_NONE); 
+1

Это работает, спасибо! – Christine