add PathLayer example
This commit is contained in:
parent
4789ecb8d7
commit
a9db7989c3
@ -33,6 +33,11 @@
|
|||||||
android:label="@string/title_activity_map" >
|
android:label="@string/title_activity_map" >
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="org.oscim.android.test.PathOverlayActivity"
|
||||||
|
android:label="@string/title_activity_map" >
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -28,6 +28,8 @@ import android.view.Menu;
|
|||||||
|
|
||||||
public class BaseMapActivity extends MapActivity {
|
public class BaseMapActivity extends MapActivity {
|
||||||
|
|
||||||
|
private final static boolean USE_CACHE = false;
|
||||||
|
|
||||||
MapView mMapView;
|
MapView mMapView;
|
||||||
VectorTileLayer mBaseLayer;
|
VectorTileLayer mBaseLayer;
|
||||||
TileSource mTileSource;
|
TileSource mTileSource;
|
||||||
@ -44,18 +46,20 @@ public class BaseMapActivity extends MapActivity {
|
|||||||
mTileSource = new OSciMap4TileSource();
|
mTileSource = new OSciMap4TileSource();
|
||||||
mTileSource.setOption("url", "http://opensciencemap.org/tiles/vtm");
|
mTileSource.setOption("url", "http://opensciencemap.org/tiles/vtm");
|
||||||
|
|
||||||
|
if (USE_CACHE) {
|
||||||
mCache = new TileCache(this, "cachedir", "testdb");
|
mCache = new TileCache(this, "cachedir", "testdb");
|
||||||
mCache.setCacheSize(512 * (1 << 10));
|
mCache.setCacheSize(512 * (1 << 10));
|
||||||
mTileSource.setCache(mCache);
|
mTileSource.setCache(mCache);
|
||||||
|
}
|
||||||
mBaseLayer = mMap.setBaseMap(mTileSource);
|
mBaseLayer = mMap.setBaseMap(mTileSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mCache.dispose();
|
|
||||||
|
if (USE_CACHE)
|
||||||
|
mCache.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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);
|
setContentView(R.layout.activity_samples);
|
||||||
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
|
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.samples);
|
||||||
linearLayout.addView(createButton(SimpleMapActivity.class));
|
linearLayout.addView(createButton(SimpleMapActivity.class));
|
||||||
|
linearLayout.addView(createButton(PathOverlayActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createButton(final Class<?> clazz) {
|
private Button createButton(final Class<?> clazz) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user