Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Polaris库自定义Android地图中显示的信息_Android_Maps_Balloon - Fatal编程技术网

如何使用Polaris库自定义Android地图中显示的信息

如何使用Polaris库自定义Android地图中显示的信息,android,maps,balloon,Android,Maps,Balloon,我使用Polaris Library for Android Maps,因为它具有群集支持: 我不依赖谷歌地图V2,因为它会在我的目标中遗漏很多设备 我需要做的是能够对气球中显示的信息进行个性化设置。 当用户点击标记时,气球应该在左边显示一张图片,中间有4行文本,另一个是右边的文本。 我与Polaris creator交换了几封邮件,他显然无法为每个使用其库的开发人员提供全面支持。他暗示我使用MapCallout View#setCustomView,但我想不出来 提前谢谢你。我终于成功了 首先

我使用Polaris Library for Android Maps,因为它具有群集支持: 我不依赖谷歌地图V2,因为它会在我的目标中遗漏很多设备

我需要做的是能够对气球中显示的信息进行个性化设置。 当用户点击标记时,气球应该在左边显示一张图片,中间有4行文本,另一个是右边的文本。

我与Polaris creator交换了几封邮件,他显然无法为每个使用其库的开发人员提供全面支持。他暗示我使用MapCallout View#setCustomView,但我想不出来


提前谢谢你。

我终于成功了

首先,我扩展了注释以添加其他字段:

public class CustomAnnotation extends Annotation {
private CustomObject cObject;

public CustomObject getCustomObject() {
    return cObject;
}

public void setCustomObject(CustomObject cObject) {
    this.cObject = cObject;
}

public CustomAnnotation(GeoPoint point, String title, String snippet,CustomObject cObject) {
    super(point, title, snippet);
    this.cObject = cObject;
}
我为详图索引视图创建了布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content"
android:paddingLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
      android:id="@+id/balloon_inner_layout"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:layout_gravity="center_vertical">
  <ImageView
      android:id="@+id/image"
      android:layout_width="50dip"
      android:layout_height="50dip"
      android:contentDescription="@string/descr_image"
      android:src="@drawable/stub"
      android:scaleType="centerCrop"
      android:layout_gravity="center_vertical"/>
  <LinearLayout
          android:paddingLeft="5dip"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical">
      <TextView
        android:id="@+id/price"
    android:textStyle="bold"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
      <TextView
    android:id="@+id/address"
    android:textStyle="bold"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
    <TextView
      android:id="@+id/sup"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"            
      android:visibility="gone"/>
    <TextView
               android:layout_height="wrap_content"
               android:layout_width="wrap_content"
               android:id="@+id/rooms"
               android:visibility="gone"/>      
          </LinearLayout>
   </LinearLayout>
就这些。
希望它能帮助一些人。

“它会从我的目标中删除许多设备”
。截至5月不到2%,预计年底不到0.1%。我的应用是针对拉丁美洲的,所以这些数字不够准确。
@Override
public void onAnnotationSelected(PolarisMapView mapView,
        MapCalloutView calloutView, int position, Annotation annotation) {
    CustomAnnotation ca = (CustomAnnotation) annotations.get(position);
    View view = (View)getLayoutInflater().inflate(R.layout.balloon_test, null);
            CustomObject object = ca.getCustomObject();
        TextView txView = (TextView)view.findViewById(R.id.field1);
        txView.setText(object.getField1());
        txView.setVisibility(View.VISIBLE);
    ...
            //set aditional data in your callout
            ...
                    calloutView.setDisclosureEnabled(true);
        calloutView.setClickable(true);
        calloutView.setCustomView(view);
        calloutView.show(mPolarisMapView, annotation.getPoint(), false);
        }