2017-03-28 89 views
2

首先,根據我的知識,Cartotype提供用於在Android,iOS和其他平臺中提供Map的API。insertMapObject函數Android返回23代碼Cartotype

從文檔我發現,符合我的需要的功能

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。

MY需要的是DRAW的線B \ W 2個座標

任何幫助將理解

回答

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

乍一看似乎只有一個點被添加到該幾何對象。你需要兩點才能畫出一條線。另外,不需要調用beginContour。

但是你提到你得到'重複對象'錯誤(23)。這是因爲已插入多個對象,ID爲ID_MEASUREMENT_TOOL。順便說一句,你可以得到的CartoType錯誤代碼常量爲Android這裏的參考:

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