Skip to content

Commit

Permalink
Map scale bar: Android new implementation, opensciencemap#84, closes o…
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Jul 21, 2016
1 parent 4eebbce commit c67b35a
Show file tree
Hide file tree
Showing 9 changed files with 889 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

import android.os.Bundle;

import org.oscim.android.MapScaleBar;
import org.oscim.android.scalebar.DefaultMapScaleBar;
import org.oscim.android.scalebar.ImperialUnitAdapter;
import org.oscim.android.scalebar.MapScaleBar;
import org.oscim.android.scalebar.MapScaleBarLayer;
import org.oscim.android.scalebar.MetricUnitAdapter;
import org.oscim.backend.CanvasAdapter;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
Expand All @@ -33,6 +37,7 @@
import org.oscim.theme.VtmThemes;

public class SimpleMapActivity extends BaseMapActivity {
private DefaultMapScaleBar mapScaleBar;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -42,14 +47,28 @@ public void onCreate(Bundle savedInstanceState) {
layers.add(new BuildingLayer(mMap, mBaseLayer));
layers.add(new LabelLayer(mMap, mBaseLayer));

MapScaleBar mapScaleBar = new MapScaleBar(mMapView);
((BitmapRenderer) mapScaleBar.getRenderer()).setPosition(GLViewport.Position.BOTTOM_LEFT);
((BitmapRenderer) mapScaleBar.getRenderer()).setOffset(5 * CanvasAdapter.dpi / 160, 0);
layers.add(mapScaleBar);
mapScaleBar = new DefaultMapScaleBar(mMap);
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
mapScaleBar.setScaleBarPosition(MapScaleBar.ScaleBarPosition.BOTTOM_LEFT);

MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
BitmapRenderer renderer = (BitmapRenderer) mapScaleBarLayer.getRenderer();
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
renderer.setOffset(5 * CanvasAdapter.dpi / 160, 0);
layers.add(mapScaleBarLayer);

mMap.setTheme(VtmThemes.DEFAULT);
}

@Override
protected void onDestroy() {
mapScaleBar.destroy();

super.onDestroy();
}

void runTheMonkey() {
themes[0] = ThemeLoader.load(VtmThemes.DEFAULT);
themes[1] = ThemeLoader.load(VtmThemes.OSMARENDER);
Expand Down
273 changes: 0 additions & 273 deletions vtm-android/src/org/oscim/android/MapScaleBar.java

This file was deleted.

Loading

0 comments on commit c67b35a

Please sign in to comment.