Skip to content

Commit 6a70c90

Browse files
NearbyParentFragment : added referer (#5417)
* NearbyParentFragment : added referer In file NearbyParentFragment.java, I added header property, i.e., the referer - http://maps.wikimedia.org/ and set tile source to wikimedia. * Reworded comments --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
1 parent 050a06b commit 6a70c90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

+12
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
import org.osmdroid.events.MapListener;
126126
import org.osmdroid.events.ScrollEvent;
127127
import org.osmdroid.events.ZoomEvent;
128+
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
128129
import org.osmdroid.util.GeoPoint;
129130
import org.osmdroid.util.constants.GeoConstants;
130131
import org.osmdroid.views.CustomZoomButtonsController;
@@ -398,7 +399,18 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
398399
presenter.setActionListeners(applicationKvStore);
399400
org.osmdroid.config.Configuration.getInstance().load(this.getContext(),
400401
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);
401406
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+
402414
if (applicationKvStore.getString("LastLocation")
403415
!= null) { // Checking for last searched location
404416
String[] locationLatLng = applicationKvStore.getString("LastLocation").split(",");

0 commit comments

Comments
 (0)