【问题标题】:How to center the coordinate of Annotation when using SKAnnotationView使用SKAnnotationView时如何使Annotation的坐标居中
【发布时间】:2014-08-19 09:00:59
【问题描述】:

我正在使用 Skobbler SDK 在我的地图视图中添加注释。 它显示完美,但我的问题是我应该如何将图像居中到注释的位置,因为发生的事情是我需要点击图像的左上角以便调用 onAnnotationSelected。它应该是被挖掘的中心。

这是我的代码:

private void applyAnnotationOnMapView() {
    annotation = new SKAnnotation();
    annotation.setUniqueID(18);
    annotation.setLocation(new SKCoordinate(121.048099, 14.572744));
    annotation.setMininumZoomLevel(5);
    SKAnnotationView imageView = new SKAnnotationView();
    imageView.setDrawableResourceId(R.drawable.poi_mapv2);
    imageView.setProperSize(32);
    annotation.setAnnotationView(imageView);
    mapView.addAnnotation(annotation);
}

谢谢

【问题讨论】:

    标签: android annotations maps skmaps


    【解决方案1】:

    创建注解时需要使用offset属性:

    试试这个(点击图片时调用onAnnotationSelected):

     final SKAnnotation annotation = new SKAnnotation(); 
                annotation.setUniqueID(2000); 
                annotation.getLocation().setLongitude(23.593701); 
                annotation.getLocation().setLatitude(46.774959); 
    
                // 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(64); 
                annotation.getOffset().setY(64); 
                annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().getMapResourcesPath() 
                        + "/.Common/ccpmedium_2d_retina.png"); 
                // real size of the image in pixels 
                annotation.setImageSize(128); 
    
                mapView.addAnnotation(annotation); 
    

    【讨论】:

    • 非常感谢!我会试试这个。
    猜你喜欢
    • 1970-01-01
    • 2016-03-22
    • 2021-04-23
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多