PDA

View Full Version : [Android] Multiple Map Instances



tcolligan
13.05.2015, 19:10
I am using the latest Skobbler AndroidStudio SDK in a project that I am working on. I have been noticing issues with creating multiple map instances though. I was hoping that someone would be able to provide some insight into how to resolve this issue.

In the app, the map normally lives in a MapFragment in the MainActivity. Sometimes, the user navigates to a separate section of the app, where they can trigger a NewMapActivity to appear which has another instance of the MapFragment on it.

This works fine, until the user decides to leave the NewMapActivity and go back to the MainActivity. The MainActivity will always crash, with the exception "com.skobbler.ngx.SKMapsInitializationException: SKMaps was not initialized. In order to initialize it, please call: SKMaps.getInstance().initializeSKMaps"

This is confusing to me, as I have obviously already made this call to initialize SKMaps, and should not have to make a second call to this method. If I make another call to this method, it will fix the crash, but I am forced to reload the map in its entirety again, which is not an acceptable user experience.

The issue can sort of be replicated using the example SDK Project. If you create a new activity (http://pastebin.com/LTABBVmd) with another map in it, and launch that Activity when the "Position Me" button is tapped. The new activity will show up with no issues, but when you go back to the original map activity, it will either crash right away, or not render the map properly, slowdown and eventually crash.

Any assistance with this issue would be greatly appreciated. Thanks!

dandronic
14.05.2015, 13:09
For 2.5 we've integrated an conditional(*) example in the demo app illustrating the flow to implement if multiple maps are to be supported. The 2.5 release will be out within the next 2 weeks (if not earlier).

(*) by conditional we mean that you will have to specifically set a flag in the manifest file for the example to show up. Multiple settings are required to make the SDK support multiple map views so the decision was taken to include the required code only when specifically desired (hence the flag in the manifest file).