android-example: add VectorLayerActivity
This commit is contained in:
parent
b174f65122
commit
7f5577ff24
@ -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>
|
@ -49,6 +49,7 @@ public class Samples extends Activity {
|
||||
linearLayout.addView(createButton(S3DBMapActivity.class));
|
||||
linearLayout.addView(createButton(JeoIndoorMapActivity.class));
|
||||
linearLayout.addView(createButton(OsmJsonMapActivity.class));
|
||||
linearLayout.addView(createButton(VectorLayerMapActivity.class));
|
||||
}
|
||||
|
||||
private Button createButton(final Class<?> clazz) {
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/package org.oscim.android.test;
|
||||
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.layers.TileGridLayer;
|
||||
import org.oscim.layers.vector.VectorLayer;
|
||||
import org.oscim.layers.vector.geometries.PointDrawable;
|
||||
import org.oscim.layers.vector.geometries.Style;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.utils.ColorUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class VectorLayerMapActivity extends BaseMapActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mMap.setTheme(VtmThemes.NEWTRON);
|
||||
|
||||
VectorLayer vectorLayer = new VectorLayer(mMap);
|
||||
|
||||
// Geometry g = new GeomBuilder()
|
||||
// .point(8.8, 53.1)
|
||||
// .point()
|
||||
// .buffer(1)
|
||||
// .get();
|
||||
//
|
||||
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
|
||||
//
|
||||
// vectorLayer.add(new PointDrawable(53.1, 8.8, Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2)
|
||||
// .build()));
|
||||
//
|
||||
// Style.Builder sb = Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2);
|
||||
//
|
||||
// Style style = sb.setFillAlpha(0.2).build();
|
||||
//
|
||||
// int tileSize = 5;
|
||||
// for (int x = -180; x < 180; x += tileSize) {
|
||||
// for (int y = -90; y < 90; y += tileSize) {
|
||||
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
|
||||
// // .build();
|
||||
//
|
||||
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
|
||||
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
|
||||
// x + tileSize - 0.1, style));
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
Style.Builder sb = Style.builder()
|
||||
.buffer(0.5)
|
||||
.fillColor(Color.RED)
|
||||
.fillAlpha(0.2);
|
||||
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
Style style = sb.buffer(Math.random() + 0.2)
|
||||
.fillColor(ColorUtil.setHue(Color.RED,
|
||||
(int) (Math.random() * 50) / 50.0))
|
||||
.fillAlpha(0.5)
|
||||
.build();
|
||||
|
||||
vectorLayer.add(new PointDrawable(Math.random() * 180 - 90,
|
||||
Math.random() * 360 - 180,
|
||||
style));
|
||||
|
||||
}
|
||||
|
||||
mMap.layers().add(vectorLayer);
|
||||
mMap.layers().add(new TileGridLayer(mMap, 0xff222222, 1.2f, 1));
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user