diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml index 2684729e..59c1f576 100644 --- a/vtm-android-example/AndroidManifest.xml +++ b/vtm-android-example/AndroidManifest.xml @@ -1,16 +1,17 @@ + - + + android:targetSdkVersion="22" /> - - - + + + + android:targetSdkVersion="22" /> + android:targetSdkVersion="22" /> \ No newline at end of file diff --git a/vtm-android/src/org/oscim/android/MapPreferences.java b/vtm-android/src/org/oscim/android/MapPreferences.java index cc11ba68..cf2e59ae 100644 --- a/vtm-android/src/org/oscim/android/MapPreferences.java +++ b/vtm-android/src/org/oscim/android/MapPreferences.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.android; import org.oscim.core.MapPosition; @@ -21,6 +37,12 @@ public class MapPreferences { this.PREFERENCES_FILE = name; } + public void clear() { + Editor editor = ctx.getSharedPreferences(PREFERENCES_FILE, Activity.MODE_PRIVATE).edit(); + editor.clear(); + editor.apply(); + } + private void putDouble(Editor editor, String key, double value) { editor.putLong(key, Double.doubleToLongBits(value)); } @@ -40,8 +62,7 @@ public class MapPreferences { putDouble(editor, KEY_LATITUDE, pos.y); putDouble(editor, KEY_LONGITUDE, pos.x); putDouble(editor, KEY_SCALE, pos.scale); - putDouble(editor, KEY_LATITUDE, pos.y); - editor.commit(); + editor.apply(); } private static boolean containsViewport(SharedPreferences prefs) { diff --git a/vtm-playground/src/org/oscim/test/MapsforgeTest.java b/vtm-playground/src/org/oscim/test/MapsforgeTest.java index e6eb2571..98cea34b 100644 --- a/vtm-playground/src/org/oscim/test/MapsforgeTest.java +++ b/vtm-playground/src/org/oscim/test/MapsforgeTest.java @@ -1,34 +1,49 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test; +import org.oscim.core.MapPosition; +import org.oscim.core.Tile; import org.oscim.gdx.GdxMap; import org.oscim.gdx.GdxMapApp; import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer; -import org.oscim.renderer.MapRenderer; import org.oscim.theme.VtmThemes; import org.oscim.tiling.source.mapfile.MapFileTileSource; +import org.oscim.tiling.source.mapfile.MapInfo; public class MapsforgeTest extends GdxMap { @Override public void createLayers() { - MapRenderer.setBackgroundColor(0xff888888); - - mMap.setMapPosition(53.072, 8.80, 1 << 15); - // mMap.setMapPosition(52.5, 13.3, 1 << 15); - MapFileTileSource tileSource = new MapFileTileSource(); - tileSource.setMapFile("/home/jeff/Downloads/bremen.map"); + tileSource.setMapFile(System.getProperty("user.home") + "/Downloads/berlin.map"); VectorTileLayer l = mMap.setBaseMap(tileSource); + mMap.setTheme(VtmThemes.DEFAULT); mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l)); - // mMap.setTheme(VtmThemes.DEFAULT); - // mMap.setTheme(VtmThemes.TRONRENDER); - mMap.setTheme(VtmThemes.OSMARENDER); + MapInfo info = tileSource.getMapInfo(); + MapPosition pos = new MapPosition(); + pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4); + mMap.setMapPosition(pos); } public static void main(String[] args) {