Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

ssss #160

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

ssss #160

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ include ':vtm-themes'
include ':vtm-gdx'
include ':vtm-desktop'
include ':vtm-android-gdx'
include ':vtm-web'
include ':vtm-web-app'
include ':vtm-web-js'
//include ':vtm-web'
//include ':vtm-web-app'
//include ':vtm-web-js'
include ':vtm-jeo'
include ':vtm-jeo-desktop'
include ':vtm-playground'
Expand Down
12 changes: 9 additions & 3 deletions vtm-android-example/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<!-- android:theme="@style/AppTheme" -->
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="org.oscim.android.test.Samples"
android:label="@string/app_name" >
Expand Down Expand Up @@ -72,6 +72,12 @@
android:name="org.oscim.android.test.OsmJsonMapActivity"
android:label="@string/title_activity_map" >
</activity>
</application>

<activity
android:name="org.oscim.android.test.VectorLayerMapActivity"
android:label="@string/title_activity_map" >
</activity>

</application>

</manifest>
3 changes: 2 additions & 1 deletion vtm-android-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dependencies {
compile project(':vtm-extras')
compile project(':vtm-themes')

compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:support-v4:22.+'
compile 'com.android.support:appcompat-v7:22.+'
eclipseCompile project(':appcompat')

compile 'com.noveogroup.android:android-logger:1.3.4'
Expand Down
2 changes: 1 addition & 1 deletion vtm-android-example/res/layout/activity_map_styler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:id="@+id/controls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#cc000000"
android:background="#ccdddddd"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
Expand Down
2 changes: 1 addition & 1 deletion vtm-android-example/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar" />
<style name="AppTheme" parent="Theme.AppCompat.Light" />

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package org.oscim.android.test;

import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.android.cache.TileCache;
import org.oscim.core.MapPosition;
import org.oscim.layers.TileGridLayer;
Expand All @@ -37,30 +35,22 @@ public class BaseMapActivity extends MapActivity {

final static boolean USE_CACHE = true;

MapView mMapView;
VectorTileLayer mBaseLayer;
TileSource mTileSource;
TileGridLayer mGridLayer;

private TileCache mCache;

protected final int mContentView;

public BaseMapActivity(int contentView) {
mContentView = contentView;
super(contentView);
}

public BaseMapActivity() {
this(R.layout.activity_map);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mContentView);

mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);

mTileSource = new OSciMap4TileSource();

Expand All @@ -76,7 +66,6 @@ public void onCreate(Bundle savedInstanceState) {
mMap.getMapPosition(pos);
if (pos.x == 0.5 && pos.y == 0.5)
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));

}

@Override
Expand All @@ -88,7 +77,7 @@ protected void onDestroy() {
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.theme_default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,58 @@
*/
package org.oscim.android.test;

import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.android.cache.TileCache;
import org.oscim.backend.canvas.Color;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.renderer.MapRenderer;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.bitmap.BitmapTileSource;
import org.oscim.tiling.source.bitmap.DefaultSources;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.os.Bundle;

public class BitmapTileMapActivity extends MapActivity {

static final Logger log = LoggerFactory.getLogger(BitmapTileMapActivity.class);

private final static boolean USE_CACHE = true;

private final TileSource mTileSource;
private final BitmapTileSource mTileSource;
protected BitmapTileLayer mBitmapLayer;

public BitmapTileMapActivity() {
//mTileSource = DefaultSources.STAMEN_TONER.build();
mTileSource = DefaultSources.OPENSTREETMAP.build();
this(DefaultSources.OPENSTREETMAP.build());
}

public BitmapTileMapActivity(TileSource tileSource) {
public BitmapTileMapActivity(BitmapTileSource tileSource) {
super(R.layout.activity_map);
mTileSource = tileSource;
}

MapView mMapView;

private TileCache mCache;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);

mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);

MapRenderer.setBackgroundColor(0xff777777);
mMap.layers().add(new TileGridLayer(mMap, Color.GRAY, 1.8f, 8));

if (mTileSource == null)
return;

if (USE_CACHE) {
mCache = new TileCache(this, null, mTileSource.getClass().getSimpleName());
String cacheFile = mTileSource.getUrl()
.toString()
.replaceFirst("https?://", "")
.replaceAll("/", "-");

log.debug("use bitmap cache {}", cacheFile);
mCache = new TileCache(this, null, cacheFile);
mCache.setCacheSize(512 * (1 << 10));
mTileSource.setCache(mCache);
}
Expand All @@ -74,7 +79,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
protected void onDestroy() {
super.onDestroy();
if (USE_CACHE)
if (mCache != null)
mCache.dispose();
}

Expand Down
53 changes: 53 additions & 0 deletions vtm-android-example/src/org/oscim/android/test/MapActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.oscim.android.test;

import org.oscim.android.MapPreferences;
import org.oscim.android.MapView;
import org.oscim.map.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;

public abstract class MapActivity extends ActionBarActivity {
public static final Logger log = LoggerFactory.getLogger(MapActivity.class);
MapView mMapView;
Map mMap;
MapPreferences mPrefs;

protected final int mContentView;

public MapActivity(int contentView) {
mContentView = contentView;
}

public MapActivity() {
this(R.layout.activity_map);
}

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mContentView);

mMapView = (MapView) findViewById(R.id.mapView);
mMap = mMapView.map();
mPrefs = new MapPreferences(MapActivity.class.getName(), this);
}

@Override
protected void onResume() {
super.onResume();

mPrefs.load(mMapView.map());
mMapView.onResume();
}

@Override
protected void onPause() {
super.onPause();

mMapView.onPause();
mPrefs.save(mMapView.map());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package org.oscim.android.test;

import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.android.filepicker.FilePicker;
import org.oscim.android.filepicker.FilterByFileExtension;
Expand Down Expand Up @@ -42,10 +41,6 @@ public class MapsforgeMapActivity extends MapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);

mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);

startActivityForResult(new Intent(this, MapFilePicker.class),
SELECT_MAP_FILE);
Expand All @@ -65,7 +60,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.theme_default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ public void onCreate(Bundle savedInstanceState) {
markerLayer.addItems(pts);

mMap.layers().add(new TileGridLayer(mMap));
mMap.setMapPosition(0, 0, 1);
}

@Override
protected void onResume() {
super.onResume();
/* ignore saved position */
mMap.setMapPosition(0, 0, 1 << 2);
mMapView.onResume();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER;

import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
Expand All @@ -43,10 +42,6 @@ public class OsmJsonMapActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);

mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);

mTileSource = new OsmWaterJsonTileSource();

Expand Down
Loading