Samples for Shadow and Overpass (#670)
This commit is contained in:
parent
8e685b7ebb
commit
31077cb637
@ -112,6 +112,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".OSciMapS3DBActivity"
|
android:name=".OSciMapS3DBActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
|
<activity
|
||||||
|
android:name=".OverpassActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".PathOverlayActivity"
|
android:name=".PathOverlayActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
@ -130,6 +133,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".RotateMarkerOverlayActivity"
|
android:name=".RotateMarkerOverlayActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
|
<activity
|
||||||
|
android:name=".ShadowActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".SimpleMapActivity"
|
android:name=".SimpleMapActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize" />
|
android:configChanges="keyboardHidden|orientation|screenSize" />
|
||||||
|
@ -9,6 +9,7 @@ configurations.all {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':vtm-android')
|
implementation project(':vtm-android')
|
||||||
|
implementation project(':vtm-extras')
|
||||||
implementation project(':vtm-http')
|
implementation project(':vtm-http')
|
||||||
implementation project(':vtm-jeo')
|
implementation project(':vtm-jeo')
|
||||||
implementation project(':vtm-json')
|
implementation project(':vtm-json')
|
||||||
|
36
vtm-android-example/res/layout/activity_shadow.xml
Normal file
36
vtm-android-example/res/layout/activity_shadow.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<org.oscim.android.MapView
|
||||||
|
android:id="@+id/mapView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#cc000000"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekBarShadow"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:max="2000"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:progress="400" />
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/toggleCurrentSun"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:onClick="onToggleCurrentSun"
|
||||||
|
android:textOn="@string/now" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -24,5 +24,6 @@
|
|||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
<string name="search_key">\'*\' or OSM key</string>
|
<string name="search_key">\'*\' or OSM key</string>
|
||||||
<string name="search_value">void or value</string>
|
<string name="search_value">void or value</string>
|
||||||
|
<string name="now">Now</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Gustl22
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.oscim.android.test;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||||
|
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||||
|
import org.oscim.layers.tile.buildings.S3DBLayer;
|
||||||
|
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||||
|
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||||
|
import org.oscim.map.Viewport;
|
||||||
|
import org.oscim.theme.VtmThemes;
|
||||||
|
import org.oscim.tiling.TileSource;
|
||||||
|
import org.oscim.tiling.source.OkHttpEngine;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||||
|
import org.oscim.tiling.source.overpass.OverpassTileSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use Overpass API data for vector layer.
|
||||||
|
* Only for developing as can be error-prone.
|
||||||
|
* Take care of overpass provider licenses.
|
||||||
|
*/
|
||||||
|
public class OverpassActivity extends MapActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
TileSource tileSource = OverpassTileSource.builder()
|
||||||
|
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||||
|
.zoomMin(15)
|
||||||
|
.zoomMax(17)
|
||||||
|
.build();
|
||||||
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
|
|
||||||
|
TileSource bitmapTileSource = DefaultSources.OPENSTREETMAP
|
||||||
|
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||||
|
.zoomMax(15)
|
||||||
|
.fadeSteps(new BitmapTileLayer.FadeStep[]{
|
||||||
|
new BitmapTileLayer.FadeStep(15, 16, 1f, 0f),
|
||||||
|
new BitmapTileLayer.FadeStep(16, Viewport.MAX_ZOOM_LEVEL, 0f, 0f)
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
mMap.layers().add(new BitmapTileLayer(mMap, bitmapTileSource));
|
||||||
|
|
||||||
|
BuildingLayer.RAW_DATA = true;
|
||||||
|
mMap.layers().add(new S3DBLayer(mMap, l));
|
||||||
|
mMap.layers().add(new LabelLayer(mMap, l));
|
||||||
|
|
||||||
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
BuildingLayer.RAW_DATA = false;
|
||||||
|
}
|
||||||
|
}
|
@ -2,8 +2,12 @@
|
|||||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016-2018 devemux86
|
* Copyright 2016-2018 devemux86
|
||||||
|
* Copyright 2016 mar-v-in
|
||||||
|
* Copyright 2016 Mathieu de Brito
|
||||||
* Copyright 2017-2018 Longri
|
* Copyright 2017-2018 Longri
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
|
* Copyright 2018 boldtrn
|
||||||
|
* Copyright 2018-2019 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -108,6 +112,7 @@ public class Samples extends Activity {
|
|||||||
linearLayout.addView(createButton(MapsforgeS3DBActivity.class));
|
linearLayout.addView(createButton(MapsforgeS3DBActivity.class));
|
||||||
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
linearLayout.addView(createButton(AtlasThemeActivity.class));
|
||||||
linearLayout.addView(createButton(POTTextureActivity.class));
|
linearLayout.addView(createButton(POTTextureActivity.class));
|
||||||
|
linearLayout.addView(createButton(ShadowActivity.class));
|
||||||
|
|
||||||
linearLayout.addView(createLabel("Raster Maps"));
|
linearLayout.addView(createLabel("Raster Maps"));
|
||||||
linearLayout.addView(createButton(BitmapTileActivity.class));
|
linearLayout.addView(createButton(BitmapTileActivity.class));
|
||||||
@ -136,5 +141,6 @@ public class Samples extends Activity {
|
|||||||
linearLayout.addView(createButton(ThemeStylerActivity.class));
|
linearLayout.addView(createButton(ThemeStylerActivity.class));
|
||||||
linearLayout.addView(createButton(JeoIndoorActivity.class));
|
linearLayout.addView(createButton(JeoIndoorActivity.class));
|
||||||
linearLayout.addView(createButton(GdxPoi3DActivity.class));
|
linearLayout.addView(createButton(GdxPoi3DActivity.class));
|
||||||
|
linearLayout.addView(createButton(OverpassActivity.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Gustl22
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.oscim.android.test;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||||
|
import org.oscim.renderer.ExtrusionRenderer;
|
||||||
|
import org.oscim.renderer.light.Sun;
|
||||||
|
|
||||||
|
public class ShadowActivity extends SimpleMapActivity implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
||||||
|
public ShadowActivity() {
|
||||||
|
super(R.layout.activity_shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SeekBar mSeekBar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
BuildingLayer.SHADOW = true;
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mSeekBar = findViewById(R.id.seekBarShadow);
|
||||||
|
mSeekBar.setOnSeekBarChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
BuildingLayer.SHADOW = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
int id = seekBar.getId();
|
||||||
|
if (id == R.id.seekBarShadow) {
|
||||||
|
Sun sun = mBuildingLayer.getExtrusionRenderer().getSun();
|
||||||
|
sun.setProgress(progress / 1000f);
|
||||||
|
sun.updatePosition();
|
||||||
|
sun.updateColor();
|
||||||
|
|
||||||
|
mMap.updateMap(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onToggleCurrentSun(View view) {
|
||||||
|
boolean isCurrentSun = ((ToggleButton) view).isChecked();
|
||||||
|
mSeekBar.setEnabled(!isCurrentSun);
|
||||||
|
ExtrusionRenderer extrusionRenderer = mBuildingLayer.getExtrusionRenderer();
|
||||||
|
extrusionRenderer.enableCurrentSunPos(isCurrentSun);
|
||||||
|
extrusionRenderer.getSun().update();
|
||||||
|
mSeekBar.setProgress((int) (extrusionRenderer.getSun().getProgress() * 1000));
|
||||||
|
mMap.updateMap(true);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016-2018 devemux86
|
* Copyright 2016-2018 devemux86
|
||||||
|
* Copyright 2019 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -39,6 +40,17 @@ import org.oscim.theme.VtmThemes;
|
|||||||
public class SimpleMapActivity extends BaseMapActivity {
|
public class SimpleMapActivity extends BaseMapActivity {
|
||||||
private DefaultMapScaleBar mapScaleBar;
|
private DefaultMapScaleBar mapScaleBar;
|
||||||
|
|
||||||
|
BuildingLayer mBuildingLayer;
|
||||||
|
LabelLayer mLabelLayer;
|
||||||
|
|
||||||
|
public SimpleMapActivity(int contentView) {
|
||||||
|
super(contentView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleMapActivity() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -48,8 +60,10 @@ public class SimpleMapActivity extends BaseMapActivity {
|
|||||||
|
|
||||||
void createLayers() {
|
void createLayers() {
|
||||||
GroupLayer groupLayer = new GroupLayer(mMap);
|
GroupLayer groupLayer = new GroupLayer(mMap);
|
||||||
groupLayer.layers.add(new BuildingLayer(mMap, mBaseLayer));
|
mBuildingLayer = new BuildingLayer(mMap, mBaseLayer);
|
||||||
groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer));
|
groupLayer.layers.add(mBuildingLayer);
|
||||||
|
mLabelLayer = new LabelLayer(mMap, mBaseLayer);
|
||||||
|
groupLayer.layers.add(mLabelLayer);
|
||||||
mMap.layers().add(groupLayer);
|
mMap.layers().add(groupLayer);
|
||||||
|
|
||||||
mapScaleBar = new DefaultMapScaleBar(mMap);
|
mapScaleBar = new DefaultMapScaleBar(mMap);
|
||||||
|
@ -68,6 +68,7 @@ public class MapsforgeTest extends GdxMapApp {
|
|||||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||||
loadTheme(null);
|
loadTheme(null);
|
||||||
|
|
||||||
|
BuildingLayer.SHADOW = SHADOWS;
|
||||||
BuildingLayer buildingLayer = s3db ? new S3DBLayer(mMap, l) : new BuildingLayer(mMap, l);
|
BuildingLayer buildingLayer = s3db ? new S3DBLayer(mMap, l) : new BuildingLayer(mMap, l);
|
||||||
mMap.layers().add(buildingLayer);
|
mMap.layers().add(buildingLayer);
|
||||||
|
|
||||||
@ -116,6 +117,9 @@ public class MapsforgeTest extends GdxMapApp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
if (SHADOWS)
|
||||||
|
BuildingLayer.SHADOW = false;
|
||||||
|
|
||||||
MapPreferences.saveMapPosition(mMap.getMapPosition());
|
MapPreferences.saveMapPosition(mMap.getMapPosition());
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user