insertMapObject函数Android返回23代码Cartotype

时间:2017-03-28 12:55:07

标签: android

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

从文档我发现了一个满足我需要的功能

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坐标

任何帮助将不胜感激

2 个答案:

答案 0 :(得分: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);

答案 1 :(得分:1)

乍一看似乎只有一个点被添加到Geometry对象中。你需要两点画一条线。此外,不需要调用beginContour。

但是你提到你得到了'重复对象'错误(23)。那是因为插入了多个id为ID_MEASUREMENT_TOOL的对象。顺便说一句,你可以在这里获得对Android的CartoType错误代码常量的引用:

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