Android 如何对几何对象添加标注,具体效果如下图,这个标注的值,是根据字段获取到的值,添加显示在地图上。
我尝试用如下代码添加,但是添加失败了。
DatasetVector vector = (DatasetVector) mapControl.getMap().getLayers().get(name).getDataset();
Recordset recordset = vector.getRecordset(false, CursorType.DYNAMIC);
recordset.moveFirst();
while (!recordset.isEOF()){
    Point2D innerPoint = recordset.getGeometry().getInnerPoint();
    String a = String.valueOf(recordset.getFieldValue(tv_layer_label_field.getText().toString()));
    String value = tv_layer_label_field.getText().toString()+":"+a;
    GeoText geoText = new GeoText();
    TextPart textPart = new TextPart(value,innerPoint);
    geoText.addPart(textPart);
    TextStyle textStyle = new TextStyle();
    textStyle.setAlignment(TextAlignment.BASELINECENTER);
    textStyle.setBackColor(new com.supermap.data.Color(textcolor));
    textStyle.setWeight(Integer.parseInt(tv_layer_label_size.getText().toString()));
    geoText.setTextStyle(textStyle);
    recordset.addNew(geoText);
    recordset.update();
    textPart.dispose();
    geoText.dispose();
    recordset.moveNext();
}
mapControl.getMap().refresh();
recordset.close();
Toast.makeText(LayerLabelActivity.this, "标注成功", Toast.LENGTH_SHORT).show();