add PathLayer example
This commit is contained in:
parent
4789ecb8d7
commit
a9db7989c3
@ -33,6 +33,11 @@
|
||||
android:label="@string/title_activity_map" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="org.oscim.android.test.PathOverlayActivity"
|
||||
android:label="@string/title_activity_map" >
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -28,6 +28,8 @@ import android.view.Menu;
|
||||
|
||||
public class BaseMapActivity extends MapActivity {
|
||||
|
||||
private final static boolean USE_CACHE = false;
|
||||
|
||||
MapView mMapView;
|
||||
VectorTileLayer mBaseLayer;
|
||||
TileSource mTileSource;
|
||||
@ -44,17 +46,19 @@ public class BaseMapActivity extends MapActivity {
|
||||
mTileSource = new OSciMap4TileSource();
|
||||
mTileSource.setOption("url", "http://opensciencemap.org/tiles/vtm");
|
||||
|
||||
|
||||
if (USE_CACHE) {
|
||||
mCache = new TileCache(this, "cachedir", "testdb");
|
||||
mCache.setCacheSize(512 * (1 << 10));
|
||||
mTileSource.setCache(mCache);
|
||||
|
||||
}
|
||||
mBaseLayer = mMap.setBaseMap(mTileSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (USE_CACHE)
|
||||
mCache.dispose();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2014 Hannes Janetzek
|
||||
*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.android.MapActivity;
|
||||
import org.oscim.android.MapView;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.PathLayer;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class PathOverlayActivity extends MapActivity {
|
||||
|
||||
MapView mMapView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map);
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
|
||||
|
||||
for (double lon = -180; lon <= 180; lon += 10) {
|
||||
PathLayer pathLayer = new PathLayer(mMap, Color.CYAN);
|
||||
pathLayer.addGreatCircle(new GeoPoint(-90, lon), new GeoPoint(90, lon));
|
||||
mMap.getLayers().add(pathLayer);
|
||||
|
||||
}
|
||||
|
||||
for (double lat = -90; lat <= 90; lat += 10) {
|
||||
List<GeoPoint> pts = new ArrayList<GeoPoint>();
|
||||
|
||||
for (double lon = -180; lon <= 180; lon += 10)
|
||||
pts.add(new GeoPoint(lat, lon));
|
||||
|
||||
PathLayer pathLayer = new PathLayer(mMap, Color.CYAN);
|
||||
pathLayer.setPoints(pts);
|
||||
|
||||
mMap.getLayers().add(pathLayer);
|
||||
}
|
||||
|
||||
|
||||
for (double lat = -90; lat <= 90; lat += 10) {
|
||||
PathLayer pathLayer = new PathLayer(mMap, Color.LTGRAY, 4);
|
||||
pathLayer.addGreatCircle(new GeoPoint(lat, -90), new GeoPoint(lat, 0));
|
||||
mMap.getLayers().add(pathLayer);
|
||||
}
|
||||
|
||||
for (double lat = -90; lat <= 90; lat += 10) {
|
||||
PathLayer pathLayer = new PathLayer(mMap, Color.LTGRAY, 4);
|
||||
mMap.getLayers().add(pathLayer);
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ public class Samples extends Activity {
|
||||
setContentView(R.layout.activity_samples);
|
||||
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
|
||||
linearLayout.addView(createButton(SimpleMapActivity.class));
|
||||
linearLayout.addView(createButton(PathOverlayActivity.class));
|
||||
}
|
||||
|
||||
private Button createButton(final Class<?> clazz) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user