Reputation: 53
I am working with the Skobbler Map API for android and it has been very good so far. Following the official “How to” i have been able to implement the map to my app. Than I could make the app download the map and use it offline.
But my goal is to have a pre bundled offline map. I have done all the steps from the “how to” but it won’t work, I keep getting the error
10-31 06:54:50.347: D/SKMaps(15168): SKMapSurfaceView----Saved map cache state [ Map Region zoom=17.0 center= [13.385000228881836,52.51665115356445]] [Display mode=MODE_2D] [Follower mode=NONE] [Compass shown=false Position = [0.0 ,0.0] ] [Rotation=true ] [Panning=true][Zooming=true] [Bearing=0.0] [Annotations=0]
10-31 06:54:50.357: E/BitmapFactory(15168): Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.example.myskobblermapbasic/files/SKMaps/res/xhdpi/icon_map_popup_navigate.png: open failed: ENOENT (No such file or directory)
10-31 06:54:50.367: E/BitmapFactory(15168): Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.example.myskobblermapbasic/files/SKMaps/res/xhdpi/icon_map_popup_arrow.png: open failed: ENOENT (No such file or directory)
10-31 06:54:50.377: D/SKMaps(15168): SKMapSurfaceView---- centerMapOnPosition [19.8171,41.3294]
10-31 06:54:50.377: D/SKMaps(15168): SKMapSurfaceView---- ON RESUME
10-31 06:54:50.527: D/SKMaps(15168): MapRenderer----onSurfaceCreated
10-31 06:54:50.527: W/Settings(15168): Setting always_finish_activities has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
10-31 06:54:50.527: D/SKMaps(15168): MapRenderer---- LinInitialized = true
10-31 06:54:50.527: D/SKMaps(15168): MapRenderer----SetInitSurfaceSetup
10-31 06:54:50.527: E/Adreno-ES11(15168): <qglDrvAPI_glDeleteTextures:371>: GL_INVALID_VALUE
10-31 06:54:50.527: A/libc(15168): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 15226 (GLThread 664)
It seems that as soon as I insert the offline map to the zip, the error is generated.
Here is my MainActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SKLogging.enableLogs(true);
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/";
}
new SKPrepareMapTextureThread(this, mapResourcesDirPath, "SKMaps.zip", this).start();
}
@Override
public void onMapTexturesPrepared(boolean prepared) {
if(prepared){
initializeLibrary();
startActivity(new Intent(MainActivity.this, MapActivity.class));
}else{
Toast.makeText(MainActivity.this, "Map resources are not prepared", Toast.LENGTH_SHORT).show();
}
}
/**
* Initializes the SKMaps framework
*/
private void initializeLibrary() {
SKMapsInitSettings initMapSettings = new SKMapsInitSettings();
// set path to map resources and initial map style
initMapSettings.setMapResourcesPaths(mapResourcesDirPath,
new SKMapViewStyle(mapResourcesDirPath + "/outdoorstyle/", "outdoorstyle.json"));
// EXAMPLE OF ADDING PREINSTALLED MAPS
initMapSettings.setPreinstalledMapsPath(mapResourcesDirPath + "/PreinstalledMaps");
//initMapSettings.setConnectivityMode(SKMaps.CONNECTIVITY_MODE_OFFLINE);
SKMaps.getInstance().initializeSKMaps(this, initMapSettings, API_KEY);
}
and my MapActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
SKMapViewHolder mapViewGroup = (SKMapViewHolder) findViewById(R.id.map_surface_holder);
mapView = mapViewGroup.getMapSurfaceView();
mapView.centerMapOnPosition(new SKCoordinate(19.8171, 41.3294));
}
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
SKMaps.getInstance().destroySKMaps();
android.os.Process.killProcess(android.os.Process.myPid());
}
Thank you,
Upvotes: 2
Views: 700
Reputation: 352
Try to init your map with
new SKPrepareMapTextureThread(this, new File(yourMapPathHere).getParent(), "SKMaps.zip", this).start();
Upvotes: 1
Reputation: 11982
Check your SKMaps.zip containing following files:
SKMaps/res/xhdpi/icon_map_popup_arrow.png
SKMaps/res/xhdpi/icon_map_popup_navigate.png
If not, you should add them.
Upvotes: 2