Could anyone tell me what I do wrong?
I can build and display Polygons on my GeometryLayer in Nutiteq
but when I try to create a custom Label aka ViewLabel is not displayed, with DefaultLabel
works fine.
I have a normal XML Layout File
<?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>
And my Code
//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);
I have tried to set the attributes of View in XML File, programmatically too as you can see but without success.
I have even tried to programm an Extension of MapListener just for my Layer with Polygons and there get data from
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
...
}
}
Thanks in Advance!
Probably the issue is that you do not measure your layout, see https://github.com/nutiteq/hellomap3d/wiki/Use-View-for-Label. You should add before webView.layout()
webView.measure(400, 300);