我刚刚开始评估项目的scobbler / scout,但我遇到了问题。
我已经设置了一个活动来使用Android上的Skobbler SDK 2.3.0,API级别18(IDE = Android Studio 1.0.2)来显示地图。地图显示并可以平移,但是缩放到缩放总是会立即杀死应用程序并出现以下错误:
java.lang.NullPointerException
at com.skobbler.ngx.map.MapRenderer.a(SourceFile:886)
at com.skobbler.ngx.map.SKMapSurfaceView.onTouchEvent(SourceFile:637)
at android.view.View.dispatchTouchEvent(View.java:7817)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
at android.view.View.dispatchPointerEvent(View.java:8025)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4668)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4556)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4318)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6302)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6240)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6211)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6382)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:177)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6355)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.Z
目前,所有初始化和显示都在同一活动中执行。 onCreate()方法是:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mapResDirPath = getFilesDir() + "/" + "SKMaps";
Log.i(TAG, "Preparing maps in " + mapResDirPath);
final SKPrepareMapTextureThread prepThread = new SKPrepareMapTextureThread(this, mapResDirPath, "SKMaps.zip", this);
prepThread.start();
while (!mapsPrepared) {
Common.sleep(100);
}
Log.i(TAG, "Maps have been prepared. Continuing");
SKMapsInitSettings settings = new SKMapsInitSettings();
//settings.setMapResourcesPaths(mapResDirPath, new SKMapViewStyle(mapResDirPath + "daystyle/", "daystyle.json"));
settings.setMapResourcesPaths(mapResDirPath, new SKMapViewStyle(mapResDirPath + "/daystyle/", "daystyle.json"));
final SKAdvisorSettings advisorSettings = settings.getAdvisorSettings();
advisorSettings.setLanguage("en");
advisorSettings.setAdvisorVoice("en");
settings.setAdvisorSettings(advisorSettings);
SKMaps.getInstance().initializeSKMaps(this, settings, "<my api key>");
setContentView(R.layout.activity_skobbler);
SKMapViewHolder mapViewGroup = (SKMapViewHolder)findViewById(R.id.skobbler_main_map);
mapViewGroup.setScaleViewEnabled(true);
mapView = mapViewGroup.getMapSurfaceView();
mapView.getMapSettings().setMapZoomingEnabled(true);
mapView.setPositionAsCurrent(new SKCoordinate(-33.0, 18.0), 1.0f, true);
}
作为测试,我已经实现了SKPrepareMapTextureListener,SKMapSurfaceListener和SKMapUpdateListener,但错误仍然存在。
任何帮助将不胜感激。
答案 0 :(得分:2)
没关系。我刚刚意识到我实现了SKMapSurfaceListener但从未调用过SKMapSurfaceView.setMapSurfaceListener()