谁能告诉我我做错了什么?
我可以在我的 GeometryLayer 上构建和显示多边形,Nutiteq
但是当我尝试创建自定义标签时,又名 ViewLabel 没有显示,DefaultLabel
工作正常。
我有一个普通的 XML 布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/farmName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/farmName"/>
<TextView
android:id="@+id/area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/area"/>
</LinearLayout>
还有我的代码
//Setting Popup Label if we click the area
LayoutInflater inflater =(LayoutInflater)this.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View labelView = inflater.inflate(R.layout.popup_field, null);
TextView farmNameTV = (TextView)labelView.findViewById(R.id.farmName);
TextView areaTV = (TextView)labelView.findViewById(R.id.area);
farmNameTV.setTextColor(Color.BLACK);
farmNameTV.setTextSize(13*scale);
farmNameTV.setText("Farm Name: "+name);
GeometricUtils geomUtils = new GeometricUtils();
double area = geomUtils.computeArea(coordinates);
areaTV.setTextColor(Color.BLACK);
areaTV.setTextSize(13*scale);
areaTV.setText("Area :"+String.valueOf(area));
labelView.layout(0, 0, 400, 300);
LabelStyle labelStyle = LabelStyle.builder().setBackgroundColor(Color.WHITE).
setEdgePadding((int) (12 * scale)).
setLinePadding((int) (6 * scale)).
setTitleFont(Typeface.create("Arial", Typeface.BOLD),
16 * scale).
setTitleColor(Color.BLACK).
setTitleAlign(Align.CENTER).
setDescriptionFont(Typeface.create("Arial",
Typeface.NORMAL),13 * scale).
setDescriptionColor(Color.BLACK).
setDescriptionAlign(Align.CENTER).
build();
Label fieldLabel = new ViewLabel(fieldname, labelView, new Handler(), labelStyle);
// Without holes!
Polygon pol = new Polygon(outerPoses, null, fieldLabel, polygonStyleSet, null);
geomLayer.add(pol);
我试图在 XML 文件中设置 View 的属性,如您所见,也以编程方式设置,但没有成功。
我什至尝试为我的带有多边形的图层编程 MapListener 的扩展,并从中获取数据
public void onVectorElementClicked(VectorElement vectorElement, double x, double y,
boolean longClick) {
if (vectorElement.getLabel() != null) {
ViewLabel label = vectorElement.getLabel();
...
And here we can get all of data of label
...
}
}
提前致谢!