Reputation: 11
I’m using the osmdroid library to use openstreetmaps in my android application, but I’m unable to load the maps on-line, using wifi. If I make de manual download of the maps (mbtiles file) and place it in the osmdroid filder in the device it works fine and they are loaded by my application, but if I want that my application loads the maps from the web in real time it doesn´t work and the maps are not loaded.
In Logcat I get the following warning:
"Problem downloading Maptile: /4/8/8 HTTP/1.1 403 Forbiden"
I have the following permissions in Manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
This is the code I use to load the maps with the osmdoid:
myOpenMapView = (MapView)findViewById(R.id.openmapview);
myOpenMapView.setBuiltInZoomControls(true);
myMapController = myOpenMapView.getController();
myMapController.setZoom(4);
Can anyone help me? Thanks
Upvotes: 0
Views: 524
Reputation: 3450
The issue mentionned by LordRaydenMK has been fixed in osmdroid 4.1.
So if this is the issue you have, you just have to update your osmdroid lib to the latest version.
Upvotes: 1
Reputation: 13321
The default Apache HttpClient user-agent was recently banned from accessing tile.openstreetmap.org (server returns 403). As a result, the Mapnik provider is no longer serving any tiles for osmdroid.
OpenStreetMap's tile usage policy ( http://wiki.openstreetmap.org/wiki/Tile_usage_policy ) says that a "Valid User-Agent identifying application" must be sent. The current user-agent osmdroid sends when it downloads a tile is "Apache-HttpClient/UNAVAILABLE (java 1.4)" which is pretty generic.
I've created a patch that will send a user-agent that is more compliant with OSM's tile usage policy. The new user-agent is "osmdroid ([package name])" where [package name] is the package name of the application using osmdroid.
The patch can be found here: http://pastebin.com/kxBh1gQ5
The patch is not very pretty, but it does its job.
Source: https://code.google.com/p/osmdroid/issues/detail?id=515
Upvotes: 0