Skip to content

Commit

Permalink
Samples: improve dual map views mapsforge#724
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Oct 15, 2017
1 parent 14df9a2 commit b195e86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ protected XmlRenderTheme getRenderTheme2() {
*/
@Override
protected float getScreenRatio() {
return 0.5f;
return 0.6f;
}

/**
* @return the screen ratio that the mapview takes up (for cache
* calculation)
*/
protected float getScreenRatio2() {
return 0.5f;
return 0.6f;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013-2014 Ludwig M Brinckmann
* Copyright 2015 devemux86
* Copyright 2015-2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand All @@ -18,7 +18,6 @@

import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.util.MapViewPositionObserver;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.download.TileDownloadLayer;
Expand All @@ -27,10 +26,8 @@
/**
* An activity with two {@link MapView MapViews} tied to each other.
*/
public class DualMapnikMapViewer extends DualMapViewer {
public class DualMapnikMapViewer extends DualSyncMapViewer {
private TileDownloadLayer downloadLayer;
private MapViewPositionObserver observer1;
private MapViewPositionObserver observer2;

@Override
protected void createLayers2() {
Expand All @@ -40,16 +37,6 @@ protected void createLayers2() {
this.mapView2.getLayerManager().getLayers().add(this.downloadLayer);
}

@Override
protected void createMapViews() {
super.createMapViews();
// any position change in one view will be reflected in the other
this.observer1 = new MapViewPositionObserver(
this.mapView.getModel().mapViewPosition, this.mapView2.getModel().mapViewPosition);
this.observer2 = new MapViewPositionObserver(
this.mapView2.getModel().mapViewPosition, this.mapView.getModel().mapViewPosition);
}

@Override
protected TileCache createTileCache2() {
int tileSize = this.mapView2.getModel().displayModel
Expand All @@ -66,13 +53,6 @@ protected void createTileCaches() {
this.tileCaches.add(createTileCache2());
}

@Override
protected void onDestroy() {
this.observer1.removeObserver();
this.observer2.removeObserver();
super.onDestroy();
}

@Override
protected void onPause() {
this.downloadLayer.onPause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@
* An activity with two synchronized MapViews for comparison.
*/
public class DualSyncMapViewer extends DualMapViewer {
private MapViewPositionObserver observer1;
private MapViewPositionObserver observer2;

@Override
protected void createMapViews() {
super.createMapViews();
new MapViewPositionObserver(this.mapView.getModel().mapViewPosition, this.mapView2.getModel().mapViewPosition);
// any position change in one view will be reflected in the other
this.observer1 = new MapViewPositionObserver(
this.mapView.getModel().mapViewPosition, this.mapView2.getModel().mapViewPosition);
this.observer2 = new MapViewPositionObserver(
this.mapView2.getModel().mapViewPosition, this.mapView.getModel().mapViewPosition);
}

@Override
protected void onDestroy() {
this.observer1.removeObserver();
this.observer2.removeObserver();
super.onDestroy();
}
}

0 comments on commit b195e86

Please sign in to comment.