Skobbler。 onAnnotationSelected不叫,当我把我自己的注释 [英] Skobbler. onAnnotationSelected not called, when I set my own annotations
本文介绍了Skobbler。 onAnnotationSelected不叫,当我把我自己的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用Skobbler地图。
当我把我自己的图标注解,onAnnotationSelected不叫。当我设置的默认图标( annotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_PURPLE);
),它的工作正常。我做错了吗?
光标= dataBaseHelper.getWritableDatabase()rawQuery(stringBuilder.toString(),NULL);
诠释计数= cursor.getCount();
的for(int i = 0; I<计数;我++){
如果(cursor.moveToPosition(ⅰ)){
SKAnnotation注释=新SKAnnotation();
annotation.setUniqueID(cursor.getInt(cursor.getColumnIndex(1)));
annotation.setLocation(新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(注释,SKAnimationSettings.ANIMATION_NONE);
解决方案
您需要设置图像 - 攻上批注,将取决于这个值的中心点。
//添加注释与图像文件
SKAnnotation注释=新SKAnnotation(13);
annotation.setLocation(新SKCoordinate(-122.434516,37.770712));
annotation.setMininumZoomLevel(5);
DisplayMetrics指标=新DisplayMetrics();
。getWindowManager()getDefaultDisplay()getMetrics(指标)。
如果(metrics.densityDpi< DisplayMetrics.DENSITY_HIGH){
//设置图像的中心点 - 攻上的注解,将取决于该值。还注释的实际GPS坐标将在图像的中心。
annotation.getOffset()setX的(16)。
。annotation.getOffset()SETY(16);
annotation.setImagePath(SKMaps.getInstance()getMapInitSettings()getMa presourcesPath()+/.Common/poi_marker.png。);
//设置在像素的图像的大小
annotation.setImageSize(32);
}其他{
//设置图像的中心点 - 攻上的注解,将取决于该值。还注释的实际GPS坐标将在图像的中心。
annotation.getOffset()setX的(32)。
。annotation.getOffset()SETY(32);
annotation.setImagePath(SKMaps.getInstance()getMapInitSettings()getMa presourcesPath()+/.Common/poi_marker_retina.png。);
//设置在像素的图像的大小
annotation.setImageSize(64); }
mapView.addAnnotation(注释,SKAnimationSettings.ANIMATION_NONE);
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);
解决方案
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);
这篇关于Skobbler。 onAnnotationSelected不叫,当我把我自己的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文