使用产品:iMobile v1010 for Android
需求:实现Android端与Web端的标绘数据互相加载
问题:目前Web使用的方法是:
plotting = L.supermap.plotting.getControl(_map, plottingurl);
sitDataManager = plotting.getSitDataManager();
sitDataManager.saveAsSmlFile("situationMap");
实现以JSON格式导出标绘数据:
{
"smlInfo": {
"SMLName": null,
"SMLDesc": null,
"SMLSeclevel": null,
"SMLDepat": null,
"SMLAuthor": null,
"SMLTime": null
},
"mapInfo": {
"zoom": 10,
"centerX": 113.80056936978474,
"centerY": 32.59979750361389
},
"layerDatas": [
{
"layerName": "plot",
"spatialAnalystUrl": null,
"useCanvas2": false,
"useCanvas": true,
"isEditable": true,
"isLocked": false,
"visibility": true,
"features": [
{
"type": "GRAPHICOBJECT",
"version": 2,
"isEdit": true,
"uuid": "4c7ceb21-2b20-4d6e-85ef-f1e440aab91b",
"associatedUuid": "",
"rotate2D": {
"x": 0,
"y": 0,
"z": 0
},
"scale2D": {
"x": 1,
"y": 0,
"z": 0
},
"libID": 22,
"code": 1002,
"algoMaxEditPts": 99999,
"algoMinEditPts": 3,
"symbolType": 2,
"symbolName": "多箭头",
"annotationPosition": 4,
"textContent": "",
"textDisplay": true,
"scaleByMap": null,
"resolution": null,
"isLocked": false,
"note": "",
"custom": null,
"subSymbols": [],
"extendProperty": [],
"avoidRegions": [],
"style": {
"fillSymbolID": 1,
"fillGradientMode": 0,
"fillAngle": 0,
"fillGradientAngle": 0,
"fillCenterOffsetX": 0,
"fillGradientOffsetRatioX": 0,
"fillCenterOffsetY": 0,
"fillGradientOffsetRatioY": 0,
"fillForeColor": {
"red": 255,
"green": 0,
"blue": 0,
"alpha": 255
},
"fillOpaqueRate": 31,
"fillBackColor": {
"red": 255,
"green": 0,
"blue": 0,
"alpha": 255
},
"fillBackOpaque": 1,
"lineColor": {
"red": 255,
"green": 0,
"blue": 0,
"alpha": 255
},
"lineWidth": 0.5291666666666667,
"lineSymbolID": 0,
"dashArray": null,
"fontStrokeWidth": "2px",
"fontBackground": false,
"fontBackgroundColor": "#ff0000",
"fontShadow": false,
"fontShadowColor": "#ff0000",
"fontShadowOffsetX": 0,
"fontShadowOffsetY": 0,
"fontSpace": 0,
"fontPercent": 100,
"strokeGradientMode": 0,
"strokeBackColor": {
"red": 255,
"green": 0,
"blue": 0,
"alpha": 255
}
},
"textStyle2D": {
"fontName": "Microsoft YaHei",
"sizeFixed": true,
"fontHeight": 3.1749999999999994,
"foreColor": {
"red": 0,
"green": 0,
"blue": 0
},
"outline": false,
"backColor": {
"red": 255,
"green": 0,
"blue": 0
},
"align": 0
},
"surroundLineColor": {
"red": 255,
"green": 255,
"blue": 0,
"alpha": 255
},
"surroundLineWidth2D": 1.0583333333333333,
"visibility": true,
"localePoints": [
{
"x": 113.81519221440601,
"y": 32.808579229595175,
"z": 0
},
{
"x": 113.66571424716648,
"y": 32.485251887414044,
"z": 0
},
{
"x": 114.06378057296735,
"y": 32.40238910122692,
"z": 0
}
],
"surroundLineType": 0,
"scaleValues": [
0
],
"subSymbolScaleValue": null,
"baseScale": null,
"strokeWidth": null,
"polylineConnectLocationPoint": false,
"arrowHeadType": 0,
"arrowBodyType": 0,
"arrowTailType": 0
}
]
}
]
}
所以,请问下,Android端应该使用什么方法,也可以实现直接导出这种JSON格式的数据?并且保持数据字段都是一样的?
另外,我用Android的API尝试导出了一份,但不知道为什么自己导出的数据,自己都无法加载?
看以下代码:
// 导出数据至文件
DatasetVector vector = (DatasetVector) dataset;
vector.toGeoJSON(new File(folder, "testGeo"));
// 装载现有的数据文件
DatasetVector vector = (DatasetVector) layer.getDataset();
vector.fromGeoJSON(new File(folder + "testGeo"));
之后提示异常信息:
SMID=20, the geometry is java.lang.Exception: Unsupported GeoJSON Object type: GRAPHICOBJECT
添加或设置geometry失败,请检查SmID和geometry的值,input GeoJSON:{"type":"Feature","geometry":{"type":"GRAPHICOBJECT","libID":100, ......