插入地图对象函数 Android 返回 23 代码 Cartotype



首先,Cartotype提供了API用于根据我的知识在Android,iOS和其他平台上提供地图。

从文档中我找到了一个满足我需求的函数

native int com.cartotype.Framework.insertMapObject  (   int     aMapHandle,
int     aMapObjectType,
String  aLayerName,
Geometry    aGeometry,
String  aStringAttributes,
int     aIntAttribute,
long    aId,
boolean     aReplace 
)       

但是他们提到的参数我无法成功获得这些参数,最终得到了

// Second or continuing measurement, add to arrays
// and draw line
iDistanceMeasurementX = extendArray(
iDistanceMeasurementX, thisPoint[0]);
iDistanceMeasurementY = extendArray(
iDistanceMeasurementY, thisPoint[1]);
// _thread.iFramework.deleteMapObjects(0,
// ID_MEASUREMENT_TOOL, ID_MEASUREMENT_TOOL, null);
// _thread.iFramework.addLineOrPolygonObject(
// "measurementtool", iDistanceMeasurementX,
// iDistanceMeasurementY,
// Framework.DEGREE_COORDS, null, 0,
// ID_MEASUREMENT_TOOL, false);

//Drawing line geometry
Geometry geometry = new Geometry(Framework.DEGREE_COORDS);
geometry.appendPoint(thisPoint[0],thisPoint[1]);
geometry.beginContour();
 try {
                                int abc = _thread.iFramework.insertMapObject(0, MapObject.LINE_TYPE, "measurementtool", geometry, null, 0,
                                        ID_MEASUREMENT_TOOL, false);
                                Toast.makeText(getContext(),abc,Toast.LENGTH_SHORT).show();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
//Drawing line with coordinates
// _thread.iFramework.insertPointMapObject(0,"measurementtool", iDistanceMeasurementX[0],iDistanceMeasurementY[0] ,MapObject.LINE_TYPE, "", 0,
// ID_MEASUREMENT_TOOL, false);
//Toast.makeText(getContext(),"Draw Line ",Toast.LENGTH_SHORT).show();
getMapAndDraw(); // Inefficient, we are drawing

那些 'abc' int 返回值 23,如果根据文档成功,则需要为 0。

我的需要是画一条线 b\w 2 坐标

任何帮助将不胜感激

谢谢@Graham

geometry = new Geometry(Framework.DEGREE_COORDS);
   iDistanceMeasurementX = extendArray(
                                    iDistanceMeasurementX, thisPoint[0]);
                            iDistanceMeasurementY = extendArray(
                                    iDistanceMeasurementY, thisPoint[1]);
geometry.appendPoint(iDistanceMeasurementX[iDistanceMeasurementX.length-1], iDistanceMeasurementY[iDistanceMeasurementY.length-1]);
                            //Drawing line geometry
                                _thread.iFramework.insertMapObject(0, MapObject.LINE_TYPE, "measurementtool", geometry, null, 0,
                                        0, false);

乍一看,似乎只向几何对象中添加了一个点。你需要两个点来画一条线。此外,不需要调用 beginContour。

但是您提到您收到"重复对象"错误(23(。这是因为使用 id ID_MEASUREMENT_TOOL插入了多个对象。顺便说一下,您可以在此处获取对Android的CartoType错误代码常量的引用:

http://www.cartotype.com/assets/android_api_doc/classcom_1_1cartotype_1_1_error.html

最新更新