anhtuanmai / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

OSMDroid no map loading while changing zoom level #435

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use offline SQLite DB. Set to zoom level 13 
2. Change to zoom level 14.

What is the expected output? What do you see instead?
I expected to see the tiles from 14 zoom level. But they are not been loaded 
and instead of them I saw tiles from 13 level, stretched to 14 level. On 15 
level I saw no tiles at all.

What version of the product are you using? On what operating system?
Android 4.0. OSMDroid 3.0.9\3.0.10

Please provide any additional information below.

Used code below:

package com.example.testprojectmaps;
import java.io.File;

import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.tileprovider.LRUMapTileCache;
import org.osmdroid.tileprovider.MapTileProviderArray;
import org.osmdroid.tileprovider.modules.IArchiveFile;
import org.osmdroid.tileprovider.modules.MBTilesFileArchive;
import org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider;
import org.osmdroid.tileprovider.modules.MapTileModuleProviderBase;
import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.tileprovider.util.SimpleRegisterReceiver;
import org.osmdroid.util.BoundingBoxE6;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MotionEvent;

public class MapActivity extends Activity {

  @SuppressWarnings("unused")
  private static final String TAG = "RouteMapActivity";

  private BoundedMapView mapView;

  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    DefaultResourceProxyImpl resProxy;
    resProxy = new DefaultResourceProxyImpl(this.getApplicationContext());

    XYTileSource tSource;
    tSource = new XYTileSource("mbtiles",
    ResourceProxy.string.offline_mode,
    8, 15, 256, ".png", "http://who.cares/");

    SimpleRegisterReceiver sr = new SimpleRegisterReceiver(this);

    String packageDir = "/Maps";
    String p = Environment.getExternalStorageDirectory() + packageDir;
    File f = new File(p, "HollandRoute.mbtiles");
    IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };

    MapTileModuleProviderBase moduleProvider;
    moduleProvider = new MapTileFileArchiveProvider(sr, tSource, files);

    MapTileModuleProviderBase[] pBaseArray;
    pBaseArray = new MapTileModuleProviderBase[] { moduleProvider };

    MapTileProviderArray provider;
    provider = new MapTileProviderArray(tSource, null, pBaseArray);

    mapView = new BoundedMapView(this, resProxy, provider);

    double north = 52.6297;
    double east  =  5.3496;
    double south = 52.1613;
    double west  =  4.4638;
    BoundingBoxE6 bBox = new BoundingBoxE6(north, east, south, west);

    mapView.setScrollableAreaLimit(bBox);
    mapView.setBuiltInZoomControls(true);

    // Zoom in and go to Amsterdam
    MapController controller = mapView.getController();
    controller.setZoom(14);
    controller.animateTo(new GeoPoint(52.373444, 4.892229));

    // Set the MapView as the root View for this Activity; done!
    setContentView(mapView);

  }

  @Override
public boolean onTouchEvent(MotionEvent event) {

    //Toast.makeText(this, "Hello", Toast.LENGTH_SHORT).show();
    return super.onTouchEvent(event);
}

@Override
  public boolean onCreateOptionsMenu(Menu menu) {
    //getMenuInflater().inflate(R.menu.activity_route_map, menu);
    return true;
  }
}

Original issue reported on code.google.com by avmalyu...@gmail.com on 29 May 2013 at 10:54

GoogleCodeExporter commented 8 years ago
Are you *sure* you have offline tiles at zoom level 14? Can you check your 
database?

Original comment by kurtzm...@gmail.com on 29 May 2013 at 12:50

GoogleCodeExporter commented 8 years ago
Same here. I got a database with levels 14, 15, 16 and 17. 14 and 15 are shown 
without a problem, but 16 and 17 will stretch from the other levels. Or if you 
start on level 17 everything will be blank until you zoom out to level 15.
Google Nexus 7, Android 4.2.2 and HTC Desire, Android 2.2.2, both wrong with 
3.0.10.
Linking my app to OsmDroid 3.0.8 solves the problem.

Original comment by zoefz...@gmail.com on 20 Jun 2013 at 6:25

GoogleCodeExporter commented 8 years ago
Thank you for the additional information. Can you debug 
DatabaseFileArchive.getInputStream() and see what happens when you are looking 
at zoom level 16 or 17. Does the method get hit? If so, why doesn't it return a 
tile? Does it get hit at zoom level 14 and 15?

Also if you have a small database that exhibits the issue, please attach it to 
this ticket.

Original comment by kurtzm...@gmail.com on 20 Jun 2013 at 11:23

GoogleCodeExporter commented 8 years ago
This is the database. As you can see the tiles are located around N 51.4788 E 
3.6158

Can I debug the code when I'm just linking to the jar-file? I'll try.

Original comment by zoefz...@gmail.com on 21 Jun 2013 at 10:23

GoogleCodeExporter commented 8 years ago
I debugged DatabaseFileArchive.getInputStream() with 3.0.10 and it is NOT hit 
on levels 16 and 17. And of course it is hit on levels 14 and 15. All 4 levels 
are hit with version 3.0.8

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 12:01

GoogleCodeExporter commented 8 years ago
FYI: my implementation of IArchiveFile

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 12:04

Attachments:

GoogleCodeExporter commented 8 years ago
Your problem is now clear to me:

XYTileSource tSource;
    tSource = new XYTileSource("mbtiles",
    ResourceProxy.string.offline_mode,
    8, 15, 256, ".png", "http://who.cares/");

You are saying that this tile source only contains tiles from zoom levels 8-15. 
Change the parameters to allow for the full range of zoom levels. We changed 
the array provider to not ask for tiles that the tile provider can't provide.

Original comment by kurtzm...@gmail.com on 27 Jun 2013 at 1:25

GoogleCodeExporter commented 8 years ago
I'm afraid you're mixing up two different problems. The topic starter has a 
database with level 8-15 with 14 and 15 not showing. So he is correct in 
limiting the zoom levels from 8 to 15.
I have a database with levels 14-17 with 16 and 17 not showing. But I'm not 
using XYTileSource, but just implementing IArchiveFile, where/how should I 
indicate the needed levels? 

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 1:41

GoogleCodeExporter commented 8 years ago
Ah, yes. What TileSource are you passing to MapTileFileArchiveProvider()?

Original comment by kurtzm...@gmail.com on 27 Jun 2013 at 1:45

GoogleCodeExporter commented 8 years ago
I'm using:
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this);
mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
File sqliteDatabaseFile = new File(kaartNaam);
LocusTiles locusTilesFileArchive = 
LocusTiles.getDatabaseFileArchive(sqliteDatabaseFile);
IArchiveFile[] files = { locusTilesFileArchive };
MapTileModuleProviderBase moduleProvider = new 
MapTileFileArchiveProvider(simpleReceiver, locusTileSource, files);
mProvider = new MapTileProviderArray(locusTileSource, null, new 
MapTileModuleProviderBase[]{ moduleProvider } );
mapView = new ZoomLimitOsmDroidMapView(this, 256, mResourceProxy, mProvider);
mapView.setMinZoomLevel(locusTilesFileArchive.getMinZoom());
mapView.setMaxZoomLevel(locusTilesFileArchive.getMaxZoom());

where "locusTilesFileArchive.getMinZoom()" gives 14 and 
"locusTilesFileArchive.getMaxZoom()" gives 17

Can it be a problem that I'm setting the min and max zoomlevels to the mapView, 
and not somehow to the tile provider? And if so, how do i correct that?

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 2:18

GoogleCodeExporter commented 8 years ago
Can you show me how locusTileSource gets created? That is the TileSource I am 
interested in.

Original comment by kurtzm...@gmail.com on 27 Jun 2013 at 2:33

GoogleCodeExporter commented 8 years ago
Arghhh! You're spot on!

Private XYTileSource locusTileSource = new XYTileSource(
"locus", ResourceProxy.string.offline_mode, 6, 15, 256, ".png", 
"http://i.dont.care.org/");

So the same as the topic starter ;-)
How did I miss that :-(

I will fix this and get back to you if it fixed my problem...

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 2:39

GoogleCodeExporter commented 8 years ago
Yep, problem fixed!
Thank you so much for your support!

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 2:41

GoogleCodeExporter commented 8 years ago
Good to know! I'd still like to know why locusTilesFileArchive.getMaxZoom() 
returned 17 if the tile source was at max 15...

Original comment by kurtzm...@gmail.com on 27 Jun 2013 at 3:02

GoogleCodeExporter commented 8 years ago
Because I read that value myself directly from the file...
I should have used moduleProvider.getMinimumZoomLevel() I suppose?!

Original comment by zoefz...@gmail.com on 27 Jun 2013 at 3:10

GoogleCodeExporter commented 8 years ago
Ah - yes, you are correct.

If the original poster (avmalyutin) would like to speak up to let us know if 
this also solves their problem then I can close this ticket. Otherwise I will 
close it after a few days.

Original comment by kurtzm...@gmail.com on 27 Jun 2013 at 3:23

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 10 Jul 2013 at 8:54