OSMDroid simple example required
Posted
by
Bex
on Stack Overflow
See other posts from Stack Overflow
or by Bex
Published on 2011-03-16T15:15:10Z
Indexed on
2011/03/16
16:10 UTC
Read the original article
Hit count: 491
android
Hi!
I am trying to create an app that uses offline maps and custom tiles. For this I have decided to use OSMDroid and have included the jar within my project. I will create my custom tiles using MOBAC.
I have been directed to these examples: http://code.google.com/p/osmdroid/source/browse/#svn%2Ftrunk%2FOpenStreetMapViewer%2Fsrc%2Forg%2Fosmdroid%2Fsamples
but I am struggling to follow them as I am new to both java and android.
I have created a class file called test (which I have created following an example!):
public class test extends Activity {
/** Called when the activity is first created. */
protected static final String PROVIDER_NAME = LocationManager.GPS_PROVIDER;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPQUESTOSM);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
map.getController().setZoom(16);
map.getController().setCenter(new GeoPoint(30266000, -97739000));
}
}
with a layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.osmdroid.views.MapView android:id="@+id/map"
android:layout_width="fill_parent" android:layout_height="fill_parent"
tilesource="MapquestOSM" android:layout_weight="1" />
</LinearLayout>
When I run this I see no map, just an empty grid. I think this is due to my tilesource but I'm not sure what I need to change it to.
Can anyone help?
Bex
© Stack Overflow or respective owner