0

我正在使用Skobbler SDK VERSION 2.5.1. 我找到了这个。但是,很少有方法不能解决。

  • SKAnnotation annotationDrawable = new SKAnnotation();
  • setHeight()
  • setWidth()
  • setDrawableResourceId()

我将其用作默认值SKAnnotationType

private void addAnnotation(Place place) {
    if (mapView != null) {
        CustomSKAnnotation skAnnotation = new CustomSKAnnotation(new Random().nextInt(), place.getName());
        skAnnotation.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_BLUE);
        skAnnotation.setLocation(new SKCoordinate(place.getLongitude(), place.getLatitude()));
        mapView.addAnnotation(skAnnotation, SKAnimationSettings.ANIMATION_PIN_DROP);
    }
}

我想将我的自定义图像添加为注释图标。可以做些什么来解决这个问题?

4

1 回答 1

2
        // add an annotation with a view
        SKAnnotation annotationFromView = new SKAnnotation(11);
        annotationFromView.setLocation(new SKCoordinate(-122.423573, 37.761349));
        annotationFromView.setMininumZoomLevel(5);
        SKAnnotationView annotationView = new SKAnnotationView();
        customView =(RelativeLayout) ((LayoutInflater)
        getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
                   R.layout.layout_custom_view, null, false);
        //If width and height of the view  are not power of 2 
        //the actual size of the image will be the next power of 2 of     
        //max(width,height).
        annotationView.setView(customView);
        annotationFromView.setAnnotationView(annotationView);
        mapView.addAnnotation(annotationFromView, SKAnimationSettings.ANIMATION_NONE);

<--- layout_custom_view.xml --->

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/customView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon_searchcenter_favorite" />

</RelativeLayout>
于 2017-01-09T13:58:55.830 回答