Search code examples
androidskmaps

How should I initialise the paths for SKMapInitSettings?


I'm trying to setup the Skobbler Maps SDK for android and I'm have trouble initialising it. I can't find on the documentation what path values should I set on 'SKMapInitSettings'. I get the following exception:

05-29 16:09:29.713: E/AndroidRuntime(18545):
com.skobbler.ngx.SKMapsPathsNotInitializedException: SKMaps paths were not
initialized. Set the following in SKMapInitSettings : mapResourcesPath,
currentMapViewStyle, mapsPath.

What are the appropriate values for these paths? Why aren't they set by default?


Solution

  • In the Android demo project there is an example on how the paths are set:

        SKMapsInitSettings initMapSettings = new SKMapsInitSettings();
        // set path to map resources and initial map style
        initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
                new SKMapViewStyle(app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));
    

    Where app.getMapResourcesDirPath points to:

        File externalDir = getExternalFilesDir(null);
    
        // determine path where map resources should be copied on the device
        if (externalDir != null) {
            mapResourcesDirPath = externalDir + "/" + "SKMaps/";
        } else {
            mapResourcesDirPath = getFilesDir() + "/" + "SKMaps/";
        }
        ((DemoApplication) getApplication()).setMapResourcesDirPath(mapResourcesDirPath);