rksahu1987 / osmdroid

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

setZoom(19) does not work #424

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi All

When the zoom level is set to 19, setZoom does not work. But when the zoom 
level is 18, it works fine. 

Incorrect:
mapView.getController().setZoom(20);   //map shows at zoom level 18
mapView.getController().setZoom(19);   //map shows at zoom level 18

Correct:
mapView.getController().setZoom(18);   //map shows at zoom level 18
mapView.getController().setZoom(17);   //map shows at zoom level 17
mapView.getController().setZoom(16);   //map shows at zoom level 16

I am using osmdroid-android-3.0.9.jar on a custom offline map. This is how I 
instantiated MapView:
MapView mapView = new MapView(this, 256); 

What should I do to fix this?

Thank you for your kind help
Cheers
Siva Chinniah

Original issue reported on code.google.com by siva.chi...@gmail.com on 25 Apr 2013 at 9:18

GoogleCodeExporter commented 8 years ago
The tile source you are using doesn't support zoom levels higher than 18. The 
default tile source is "mapnik" which only supports up to zoom level 18.

Original comment by kurtzm...@gmail.com on 26 Apr 2013 at 1:52

GoogleCodeExporter commented 8 years ago
Hi Marc

Thank you for your invaluable feedback. So what tile source do I need to use to 
go beyond zoom level 18 and how?

Once again, thank you for your input.
Cheers
Siva

Original comment by siva.chi...@gmail.com on 26 Apr 2013 at 3:30

GoogleCodeExporter commented 8 years ago
You should either create a new tile source that correctly reflects your true 
maximum zoom level, or you can use setMaxZoomLevel to override the tile 
source's maximum zoom level.

Original comment by kurtzm...@gmail.com on 26 Apr 2013 at 4:48

GoogleCodeExporter commented 8 years ago
Thank you for your quick response. Greatly appreciate it.

setMaxZoomLevel is not a method within MapView in osmdroid-android-3.0.9. 
However, the source codes do have this method but when compile it and 
referenced it to my application, the map did not show up.

I tried to create a new tile source but did not work. I am new to this 
framework and so I am unsure how to do it. Here is the code:
final MapTileProviderBasic tileProvider = new 
MapTileProviderBasic(getApplicationContext());

        final ITileSource tileSource = new XYTileSource("maps", null, 11, 21, 256, ".png");

        tileProvider.setTileSource(tileSource);
        final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
        tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
        mapView.getOverlays().add(tilesOverlay);

Original comment by siva.chi...@gmail.com on 26 Apr 2013 at 8:02

GoogleCodeExporter commented 8 years ago
You need to have a tile source that actually contains data beyond 18. So you 
can create a tile source based on the Mapnik tile source and that will allow 
you to zoom beyond 18, but you won't get any tiles (in most areas?). If you 
still want to do this:

new XYTileSource("Mapnik", ResourceProxy.string.mapnik, 11, 21, 256, ".png", 
"http://tile.openstreetmap.org/")

Take a look at TileSourceFactory to see the pre-loaded available tile sources.

Original comment by kurtzm...@gmail.com on 29 Apr 2013 at 1:56

GoogleCodeExporter commented 8 years ago
Thank you for your helpful hint, Marc

When I added your code snippet to our application(see below), I get the 
openstreet map tiles in the background. I also get our own custom satellite 
imagery tiles on top of it. But the zoom level still doesn’t go beyond 18. 
What I want is only our custom map displayed and we do not need openstreet map. 
We also want to be able to zoom beyond 18. Though our custom tiles has zoom 
levels from 11 to 21, why can’t we zoom beyond 18. What is wrong with our 
codes?

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        MapView mapView = new MapView(this, 256); //constructor        
        // Add tiles layer with custom tile source
        final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());

        final ITileSource tileSource = new XYTileSource("Mapnik", ResourceProxy.string.mapnik, 11, 21, 256, ".png","http://tile.openstreetmap.org/");

    tileProvider.setTileSource(tileSource);
    final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
    tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
    mapView.getOverlays().add(tilesOverlay);

       mapView.setBuiltInZoomControls(true);
       mapView.setMultiTouchControls(true);        
       setContentView(mapView);

        mapView.getController().setZoom(20); 

        mapView.getController().setCenter(new GeoPoint(41.403918,-95.003335));
        mapView.setUseDataConnection(false); //keeps the mapView from loading online tiles using network connection.
    }

Original comment by siva.chi...@gmail.com on 29 Apr 2013 at 5:27

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
You don't want to add a new TilesOverlay. You want to set the tile source for 
the existing tile provider.

mapView.setTileSource(tileSource);

Original comment by kurtzm...@gmail.com on 2 May 2013 at 12:51

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 2 May 2013 at 12:51