Skobbler. onAnnotationSelected not called, when I set my own annotations

六月ゝ 毕业季﹏ 提交于 2019-12-07 22:34:48

问题


I use Skobbler Maps. When I set my own icons as annotations, onAnnotationSelected isn't called. And when I set default icons (annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);), It worked properly. What I'm doing wrong?

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);

回答1:


You need to set the center point of the image- tapping on an annotation will depend on this value.

// 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);


来源:https://stackoverflow.com/questions/27589941/skobbler-onannotationselected-not-called-when-i-set-my-own-annotations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!