使用版本 SuperMap iMobile 11i(2023) SP1 for Android(2023/9/21)
仿照示例代码写的,
selection.getCount()=1, fieldInfos.getCount();也有值
管线也被选中了 缓存格式是s3mb的 但是layer3d.getAllFieldValueOfLastSelectedObject()获取的值一直是null
sceneControl.setAction(Action3D.PANSELECT3D)
sceneControl.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Layer3Ds layer3ds = sceneControl.getScene().getLayers();
// 返回给定的三维图层集合中三维图层对象的总数。
int count = layer3ds.getCount();
if (count > 0) {
for (int i = 0; i < count; i++) {
Layer3D layer = layer3ds.get(i);
// 遍历count之后,得到三维图层对象
// 返回三维图层的选择集。
if (layer == null) {
continue;
}
final Selection3D selection = layer.getSelection();
if (selection == null) {
continue;
}
if (layer.getName() == null) {
continue;
}
// 获取选择集中对象的总数
Log.i("strstr", selection.getCount() + "");
if (selection.getCount() > 0) {
// 返回选择集中指定几何对象的系统 ID
// 本地数据获取
runOnUiThread(new Runnable() {
@Override
public void run() {
queryInfoBubblePopupWindow.m_QueryInfoData.clear();
queryInfoBubblePopupWindow.show(sceneControl, motionEvent.getX(), motionEvent.getY());
}
});
}
FieldInfos fieldInfos = layer.getFieldInfos();
vect(selection, layer, fieldInfos, queryInfoBubblePopupWindow);
}
}
return false;
}
});
// 属性查询时的矢量数据
public static void vect(Selection3D selection, Layer3D layer, FieldInfos fieldInfos,
QueryInfoBubblePopupWindow queryInfoBubble) {
Feature3D feature = null;
Layer3DOSGBFile layer3d = null;
if (layer.getType() == Layer3DType.OSGBFILE) {
layer3d = (Layer3DOSGBFile) layer;
} else if (layer.getType() == Layer3DType.VECTORFILE) {
feature = selection.toFeature3D();
}
int count = fieldInfos.getCount();
if (count > 0) {
Object[] str = layer3d.getAllFieldValueOfLastSelectedObject();
if (str == null) {
return;
}
// Log.i("strstr3333",str.toString());
for (int j = 0; j < count; j++) {
String name = fieldInfos.get(j).getName();
String strValue;
Object value;
if (feature == null) {
value = str[j];
} else {
value = feature.getFieldValue(name);
}
if (value.equals("NULL")) {
strValue = "";
} else {
strValue = value.toString();
}
queryInfoBubble.additem(name + ":", strValue);
}
}
}