Saturday, January 5, 2008

Android: Simple Map Viewer

It's so much easy to show map in Android, just 4 lines of code. In eclipse, create an Android project, in the projects main class extend it by MapActivity. Then in main layout file (main.xml) add the following lines


android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />


The java file will look something like it

public class MapViewer extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
}
}


Fix imports by pressing Ctrl+Shift+O
Run the project, u will see the map, no key event is attached so use your mouse to
move or zoomin/out.

Here is the source code

0 Comments:

Post a Comment