|
125 | 125 | import org.osmdroid.events.MapListener; |
126 | 126 | import org.osmdroid.events.ScrollEvent; |
127 | 127 | import org.osmdroid.events.ZoomEvent; |
| 128 | +import org.osmdroid.tileprovider.tilesource.TileSourceFactory; |
128 | 129 | import org.osmdroid.util.GeoPoint; |
129 | 130 | import org.osmdroid.util.constants.GeoConstants; |
130 | 131 | import org.osmdroid.views.CustomZoomButtonsController; |
@@ -398,7 +399,18 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved |
398 | 399 | presenter.setActionListeners(applicationKvStore); |
399 | 400 | org.osmdroid.config.Configuration.getInstance().load(this.getContext(), |
400 | 401 | PreferenceManager.getDefaultSharedPreferences(this.getContext())); |
| 402 | + |
| 403 | + // Use the Wikimedia tile server, rather than OpenStreetMap (Mapnik) which has various |
| 404 | + // restrictions that we do not satisfy. |
| 405 | + mapView.setTileSource(TileSourceFactory.WIKIMEDIA); |
401 | 406 | mapView.setTilesScaledToDpi(true); |
| 407 | + |
| 408 | + // Add referer HTTP header because the Wikimedia tile server requires it. |
| 409 | + // This was suggested by Dmitry Brant within an email thread between us and WMF. |
| 410 | + org.osmdroid.config.Configuration.getInstance().getAdditionalHttpRequestProperties().put( |
| 411 | + "Referer", "http://maps.wikimedia.org/" |
| 412 | + ); |
| 413 | + |
402 | 414 | if (applicationKvStore.getString("LastLocation") |
403 | 415 | != null) { // Checking for last searched location |
404 | 416 | String[] locationLatLng = applicationKvStore.getString("LastLocation").split(","); |
|
0 commit comments