简体   繁体   中英

Osmdroid don't load map from valid source

I'm playing around with Osmdroid API and i can see the basic map. But when i try to set custom tile source - i got a full hands of 404 HTTP errors for each tile. I've checked my url request for tile in desktop browser and it works ok, returning proper tile. I suppose, osm library do wrong with http request building. My question is - how can i log http requests, that osm make for tiles? Most proxy solutions works with mobile browser and not with apps. Is there some logging tools on osm api??

Here is the code:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MapView map = (MapView) findViewById(R.id.map);
        ITileSource tileSource = new XYTileSource("KGKMap", 3, 18, 256, ".png", new String[]{"http://map2.kgk-global.com/tiles/tile.py"});
        map.setTileSource(tileSource);
        map.setBuiltInZoomControls(true);
    }
}

And what i get:

01-21 04:27:40.306 25696-25737/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/0/1 HTTP response: Not Found
01-21 04:27:40.306 25696-25746/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/2/2 HTTP response: Not Found
01-21 04:27:40.321 25696-25737/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/5/5 HTTP response: Not Found
01-21 04:27:40.325 25696-25746/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/7/1 HTTP response: Not Found
01-21 04:27:40.335 25696-25737/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/6/1 HTTP response: Not Found
01-21 04:27:40.338 25696-25746/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/4/1 HTTP response: Not Found
01-21 04:27:40.357 25696-25737/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/3/1 HTTP response: Not Found
01-21 04:27:40.357 25696-25746/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/2/1 HTTP response: Not Found
01-21 04:27:40.369 25696-25737/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/6/2 HTTP response: Not Found
01-21 04:27:40.373 25696-25746/kravtsov.evgeny.openstreetmap W/OsmDroid: Problem downloading MapTile: /3/4/5 HTTP response: Not Found

Problem solved. Http queries, generated by OSM, did not match my tile server protocol. Solution was simple - extend XYTileSource class from OSM. In getTileURLString() method you can make any form for http query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM