我试图将SKCoordinates
列表添加到SKMapSurfaceview
中的SKPolyline
映射中。执行SKSurfaceView.addPolyline( SKPolyline )
时
我从libc收到致命信号6 SIGABRT。
MapActivity.java
public class MapActivity extends BaseRouteActivity
{
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
SKMapSurfaceView mapView = SKMapViewHolder mapHolder = (SKMapViewHolder)
findViewById(map_target);
mapView = mapHolder.getMapSurfaceView();
mapView.setMapSurfaceListener(this);
List<SKCoordinate> coordinates = new ArrayList<SKCoordinate>();
coordinates.add( new SKCoordinate( 52.390846319385254, 4.643051476057394 ) );
coordinates.add( new SKCoordinate( 52.391088576419605, 4.643212408598288 ) );
SKPolyline polyline = new SKPolyline();
polyline.setNodes(coordinates);
mapView.addPolyline(polyline);
}
...
}
Logcat错误
8009-8009/com.my.app A/libc﹕ Fatal signal 6 (SIGABRT) at 0x00001f49 (code=-6), thread 8009 (y.app)
我曾尝试将
addPolyline
包装在UIThread/AsyncTask
中,因为我听说Android会杀死UI阻止功能中的所有网络流量,但无济于事。我想念什么?
编辑#1:
在LogCat中进行更多挖掘后,出现此错误:
JNI WARNING: GetFloatArrayElements received null array
in Lcom/skobbler/ngx/map/MapRenderer;.addobjectpolyline:([D[D[F[FIIII)I (GetFloatArrayElements)
最佳答案
这是一个SDK问题,将在下一版本中修复。如果未指定用于设置SKPolyline对象样式的color和outlineColor属性,则会发生崩溃。为了避免崩溃,您应该为折线指定样式属性,如下面的代码所示:
List<SKCoordinate> coordinates = new ArrayList<SKCoordinate>();
coordinates.add( new SKCoordinate( 52.390846319385254, 4.643051476057394 ) );
coordinates.add( new SKCoordinate( 52.391088576419605, 4.643212408598288 ) );
SKPolyline polyline = new SKPolyline();
polyline.setNodes(coordinates);
// set styling properties (crash will occur if color or outlineColor are not specified)
polyline.setLineSize(9);
polyline.setOutlineSize(4);
polyline.setColor(new float[] {0, 0, 0, 1});
polyline.setOutlineColor(new float[] {0, 0, 0, 1});
polyline.setOutlineDottedPixelsSolid(6);
polyline.setOutlineDottedPixelsSkip(0);
mapView.addPolyline(polyline);