Skip to content

Commit 56d9f9e

Browse files
committed
Fixed: OSM refuses to download tiles. New version: 0.3.2
1 parent 48bb42f commit 56d9f9e

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

osmdroidandroid/src/main/java/org/osmdroid/http/HttpClientFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
*/
2323
public class HttpClientFactory {
2424

25+
public static String userAgent = "osmdroid";
26+
2527
private static IHttpClientFactory mFactoryInstance = new IHttpClientFactory() {
2628
@Override
2729
public HttpClient createHttpClient() {
2830
final DefaultHttpClient client = new DefaultHttpClient();
29-
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "osmdroid");
31+
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, HttpClientFactory.userAgent);
3032
return client;
3133
}
3234
};

osmdroidandroid/src/main/java/org/osmdroid/tileprovider/constants/OpenStreetMapTileProviderConstants.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public interface OpenStreetMapTileProviderConstants {
1515

16-
public static final boolean DEBUGMODE = false;
16+
public static final boolean DEBUGMODE = true;
1717
public static final boolean DEBUG_TILE_PROVIDERS = false;
1818

1919
/** Minimum Zoom Level */
@@ -28,16 +28,15 @@ public interface OpenStreetMapTileProviderConstants {
2828
/** Base path for osmdroid files. Zip files are in this folder. */
2929
public static final File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(),
3030
"osmdroid");
31-
3231
/** Base path for tiles. */
3332
public static final File TILE_PATH_BASE = new File(OSMDROID_PATH, "tiles");
3433

3534
/** add an extension to files on sdcard so that gallery doesn't index them */
3635
public static final String TILE_PATH_EXTENSION = ".tile";
3736

3837
/**
39-
* Initial tile cache size. The size will be increased as required by calling {@link
40-
* LRUMapTileCache.ensureCapacity(int)} The tile cache will always be at least 3x3.
38+
* Initial tile cache size. The size will be increased as required by calling
39+
* The tile cache will always be at least 3x3.
4140
*/
4241
public static final int CACHE_MAPTILECOUNT_DEFAULT = 9;
4342

osmdroidandroid/src/main/java/org/osmdroid/tileprovider/tilesource/TileSourceFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public static void addTileSource(final ITileSource mTileSource) {
6262

6363
public static final OnlineTileSourceBase MAPNIK = new XYTileSource("Mapnik",
6464
ResourceProxy.string.mapnik, 0, 18, 256, ".png", new String[] {
65-
"http://a.tile.openstreetmap.org/",
66-
"http://b.tile.openstreetmap.org/",
67-
"http://c.tile.openstreetmap.org/" });
65+
"https://a.tile.openstreetmap.org/",
66+
"https://b.tile.openstreetmap.org/",
67+
"https://c.tile.openstreetmap.org/" });
6868

6969
public static final OnlineTileSourceBase CYCLEMAP = new XYTileSource("CycleMap",
7070
ResourceProxy.string.cyclemap, 0, 17, 256, ".png", new String[] {

quickRouteMap/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
package="com.dpm.quickroutemap"
5-
android:versionCode="20170900"
6-
android:versionName="0.3.1" >
5+
android:versionCode="20190516"
6+
android:versionName="0.3.2" >
77

88
<uses-sdk
99
android:minSdkVersion="10"

quickRouteMap/src/main/java/com/dpm/quickroutemap/QuickRouteMapActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import org.osmdroid.api.IGeoPoint;
1010
import org.osmdroid.api.IMapController;
11+
import org.osmdroid.http.HttpClientFactory;
1112
import org.osmdroid.util.GeoPoint;
1213
import org.osmdroid.views.MapView;
1314
import org.osmdroid.views.overlay.OverlayManager;
@@ -84,7 +85,8 @@ public void onCreate(Bundle savedInstanceState) {
8485
setContentView(R.layout.main);
8586

8687
_connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
87-
88+
89+
HttpClientFactory.userAgent = getPackageName();
8890
_mapView = (MapView) findViewById(R.id.mapview);
8991
_tilesFetcher = new TilesFetcher(_mapView);
9092
_tilesFetcher.FetchFinished.add(new EventDispatcher<EventArgs>() {

0 commit comments

Comments
 (0)