Improve various samples examples, #32
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.oscim.android.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="10"
|
||||
android:targetSdkVersion="21" />
|
||||
android:targetSdkVersion="22" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
* 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
|
||||
@@ -14,7 +17,6 @@
|
||||
*/
|
||||
package org.oscim.android.test;
|
||||
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.android.filepicker.FilePicker;
|
||||
import org.oscim.android.filepicker.FilterByFileExtension;
|
||||
import org.oscim.android.filepicker.ValidMapFile;
|
||||
@@ -35,9 +37,6 @@ import android.view.MenuItem;
|
||||
public class MapsforgeMapActivity extends MapActivity {
|
||||
private static final int SELECT_MAP_FILE = 0;
|
||||
|
||||
MapView mMapView;
|
||||
MapFileTileSource mTileSource;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -91,34 +90,21 @@ public class MapsforgeMapActivity extends MapActivity {
|
||||
if (intent.getStringExtra(FilePicker.SELECTED_FILE) == null)
|
||||
return;
|
||||
|
||||
mTileSource = new MapFileTileSource();
|
||||
MapFileTileSource tileSource = new MapFileTileSource();
|
||||
String file = intent.getStringExtra(FilePicker.SELECTED_FILE);
|
||||
if (mTileSource.setMapFile(file)) {
|
||||
if (tileSource.setMapFile(file)) {
|
||||
|
||||
VectorTileLayer l = mMap.setBaseMap(mTileSource);
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
MapInfo info = mTileSource.getMapInfo();
|
||||
if (info.boundingBox != null) {
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(info.boundingBox,
|
||||
Tile.SIZE * 4,
|
||||
Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
Samples.log.debug("set position {}", pos);
|
||||
} else if (info.mapCenter != null) {
|
||||
|
||||
double scale = 1 << 8;
|
||||
if (info.startZoomLevel != null)
|
||||
scale = 1 << info.startZoomLevel.intValue();
|
||||
|
||||
mMap.setMapPosition(info.mapCenter.getLatitude(),
|
||||
info.mapCenter.getLongitude(),
|
||||
scale);
|
||||
}
|
||||
MapInfo info = tileSource.getMapInfo();
|
||||
MapPosition pos = new MapPosition();
|
||||
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
|
||||
mMap.setMapPosition(pos);
|
||||
mPrefs.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user