报错信息如下
java.lang.NullPointerException: Attempt to invoke virtual method 'double com.supermap.imobilelite.maps.BoundingBox.getLeft()' on a null object reference
at com.supermap.imobilelite.maps.ProjectionUtil.<init>(ProjectionUtil.java:63)
at com.supermap.imobilelite.maps.Projection.<init>(Projection.java:53)
at com.supermap.imobilelite.maps.AbstractTileLayerView.initProjection(AbstractTileLayerView.java:209)
at com.supermap.imobilelite.maps.MapView.reInitProjectionToLayers(MapView.java:2610)
at com.supermap.imobilelite.maps.MapView.access$1000(MapView.java:66)
at com.supermap.imobilelite.maps.MapView$InnerOnStatusChangedListener.onStatusChanged(MapView.java:2657)
at com.supermap.imobilelite.maps.LayerView$2.handleMessage(LayerView.java:2750)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5601)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
经过多次测试,以任何方式添加第二个图层时均会报错,而且出现第二个图层即使没有添加,只要定义了,也会显示在地图中的情况,地图容器在一个Fragement中。添加图层的代码如下
LayerView layerView = new LayerView(getActivity());
LayerView layerView_stallite = new LayerView(getActivity());
layerView.setURL(url1);
layerView.setURL(url2);
//加载地图图层
LayerView[] layerViews=new LayerView[2];
layerViews[0]=layerView;
layerViews[1]=layerView_stallite;
m_mapView.addLayers(layerViews); //m_mapV已定义并绑定视图
第二种方法
LayerView layerView = new LayerView(getActivity());
LayerView layerView_stallite = new LayerView(getActivity());
layerView.setURL(url1);
layerView.setURL(url2);
//设置地图缩放
m_mapView.setBuiltInZoomControls(false);
//加载地图图层
m_mapView.addLayer(layerView);
m_mapView.addLayer(layerView_stallite);
两种方法都会报同样的错误。