Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Update osmdroid to v6.1.8
Browse files Browse the repository at this point in the history
This commit aims to get Mapnik working for newer Android versions,
which is done by upgrading osmdroid to latest. This update implies
some porting work :

- use Double instead of int argument when calling setMinZoomLevel.

- enhance osmdroid configuration : call 'load' to ensure config
(github.com/osmdroid/osmdroid/wiki/How-to-use-the-osmdroid-library)
and customize user-agent to access tiles following recommendations
(github.com/osmdroid/osmdroid/wiki/Important-notes-on-using-osmdroid-
in-your-app#set-the-http-user-agent-variable).

- replace the discarded OpenCycleMap tile source by HikeBikeMap.
  • Loading branch information
francoisfds committed Nov 29, 2020
1 parent ac04178 commit e1af67f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
}

dependencies {
compile 'org.osmdroid:osmdroid-android:5.6.4'
compile 'org.osmdroid:osmdroid-android:6.1.8'
compile 'com.github.MKergall:osmbonuspack:6.3'
compile 'com.android.support:support-v4:23.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import org.osmdroid.api.IMapController;
import org.osmdroid.bonuspack.clustering.GridMarkerClusterer;
import org.osmdroid.config.Configuration;
import org.osmdroid.events.MapEventsReceiver;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
Expand All @@ -53,6 +54,7 @@
import java.util.ArrayList;

import be.brunoparmentier.openbikesharing.app.R;
import be.brunoparmentier.openbikesharing.app.BuildConfig;
import be.brunoparmentier.openbikesharing.app.db.StationsDataSource;
import be.brunoparmentier.openbikesharing.app.models.Station;
import be.brunoparmentier.openbikesharing.app.models.StationStatus;
Expand Down Expand Up @@ -96,6 +98,10 @@ protected void onCreate(Bundle savedInstanceState) {
stationsDataSource = new StationsDataSource(this);
ArrayList<Station> stations = stationsDataSource.getStations();

final Context context = getApplicationContext();
Configuration.getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context));
Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);

map = (MapView) findViewById(R.id.mapView);
stationMarkerInfoWindow = new StationMarkerInfoWindow(R.layout.bonuspack_bubble, map);

Expand All @@ -118,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {

map.setMultiTouchControls(true);
map.setBuiltInZoomControls(true);
map.setMinZoomLevel(3);
map.setMinZoomLevel(Double.valueOf(3));

/* map tile source */
String mapLayer = settings.getString(PREF_KEY_MAP_LAYER, "");
Expand All @@ -127,7 +133,7 @@ protected void onCreate(Bundle savedInstanceState) {
map.setTileSource(TileSourceFactory.MAPNIK);
break;
case MAP_LAYER_CYCLEMAP:
map.setTileSource(TileSourceFactory.CYCLEMAP);
map.setTileSource(TileSourceFactory.HIKEBIKEMAP);
break;
case MAP_LAYER_OSMPUBLICTRANSPORT:
map.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
Expand All @@ -36,6 +37,7 @@
import android.widget.Toast;

import org.osmdroid.api.IMapController;
import org.osmdroid.config.Configuration;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
Expand All @@ -48,6 +50,7 @@
import java.util.TimeZone;

import be.brunoparmentier.openbikesharing.app.R;
import be.brunoparmentier.openbikesharing.app.BuildConfig;
import be.brunoparmentier.openbikesharing.app.db.StationsDataSource;
import be.brunoparmentier.openbikesharing.app.models.Station;
import be.brunoparmentier.openbikesharing.app.models.StationStatus;
Expand Down Expand Up @@ -79,6 +82,10 @@ protected void onCreate(Bundle savedInstanceState) {

station = (Station) getIntent().getSerializableExtra(KEY_STATION);

final Context context = getApplicationContext();
Configuration.getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context));
Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);

map = (MapView) findViewById(R.id.mapView);
final GeoPoint stationLocation = new GeoPoint((int) (station.getLatitude() * 1000000),
(int) (station.getLongitude() * 1000000));
Expand All @@ -93,7 +100,7 @@ protected void onCreate(Bundle savedInstanceState) {
map.setTileSource(TileSourceFactory.MAPNIK);
break;
case MAP_LAYER_CYCLEMAP:
map.setTileSource(TileSourceFactory.CYCLEMAP);
map.setTileSource(TileSourceFactory.HIKEBIKEMAP);
break;
case MAP_LAYER_OSMPUBLICTRANSPORT:
map.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<string name="pref_title_version">Version</string>
<string name="pref_map_layer_title">Map layer</string>
<string name="pref_map_layer_mapnik" translatable="false">Mapnik</string>
<string name="pref_map_layer_cyclemap" translatable="false">OpenCycleMap</string>
<string name="pref_map_layer_cyclemap" translatable="false">Hike &amp; Bike Map</string>
<string name="pref_map_layer_osmpublictransport" translatable="false">OSMPublicTransport</string>
<string name="pref_title_strip_station_id">Strip station ID</string>
<string name="pref_title_strip_station_id_summary">
Expand Down

0 comments on commit e1af67f

Please sign in to comment.