Package com. njupt. bmap_helloworld; import java. util. arrayList; import java. util. list; import com. baidu. mapapi. BMapManager; import com. baidu. mapapi. geoPoint; import com. baidu. mapapi. itemizedOverlay; import com. baidu. mapapi. MKGeneralListener; import com. baidu. mapapi. mapActivity; import com. baidu. mapapi. mapController; import com. baidu. mapapi. mapView; import com. baidu. mapapi. overlayItem; import android. OS. bundle; import android. app. activity; import android. graphics. drawable. drawable; import android. view. menu; import android. widget. toast; public class MainActivity extends MapActivity {private MapView mapView; // controls related to Baidu map private BMapManager bMapManager; // the engine for loading maps private String keyString = "Hangzhou "; // key private MapController mapController of Baidu map; // Add some controls on Baidu map, such Large or narrow control @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); mapView = (MapView) findViewById (R. id. bmapView); bMapManager = new BMapManager (MainActivity. this); // The key bMapManager must be loaded. init (keyString, new MKGeneralListener () {@ Override public void onGetPermissionState (int arg0) {if (arg0 = 300) {Toast. makeText (MainActivity. This, "The entered key is incorrect. Please verify... ", 1 ). show () ;}@ Override public void onGetNetworkState (int arg0) {// TODO Auto-generated method stub }}); initMapActivity (bMapManager); mapView. setBuiltInZoomControls (true); // you can set the zoom function mapController = mapView. getController (); mapController. setZoom (12); // set the zoom level // mapView. setTraffic (true); displays the traffic map // mapView. setSatellite (true); displays the satellite map Drawable drawable = getResources (). get Drawable (R. drawable. iconmarka); mapView. getOverlays (). add (new MyOverLayItem (drawable);} public class MyOverLayItem extends ItemizedOverlay <OverlayItem> {private List <OverlayItem> list = new ArrayList <OverlayItem> (); // define a set of coordinates, each of which is double-type private double mLat1 = 39.90923; // latitude private double mLon1 = 116.397428; // longitude private double mLat2 = 39.9022; private double mLon2 = 116.3922; private double mLa T3 = 39.917723; private double mLon3 = 116.37222; // used to mark coordinates on a map. Use an image to mark public MyOverLayItem (Drawable drawable) {super (drawable ); // GeoPoint geoPoint1 = new GeoPoint (int) (mLat1 * 1E6), (int) (mLon1 * 1E6) of the first group of data on the map )); geoPoint geoPoint2 = new GeoPoint (int) (mLat2 * 1E6), (int) (mLon2 * 1E6); GeoPoint geoPoint3 = new GeoPoint (int) (mLat3*1E6 ), (int) (mLon3 * 1E6); list. add (new OverlayItem (geoPoint1, "Poin T1 "," Point1 "); list. add (new OverlayItem (geoPoint2, "Point2", "Point2"); list. add (new OverlayItem (geoPoint3, "Point3", "Point3"); populate (); // refresh the map, if this parameter is not added, NullPointException} will be returned. // each coordinate in the list set @ Override protected OverlayItem createItem (int arg0) {return list. get (arg0) ;}@ Override public int size () {return list. size () ;}@ Override protected boolean onTap (int I) {// set the Click Event Toast. makeText (MainAc Tietong. this, list. get (I ). getSnippet (), 1 ). show (); return true ;}}@ Override protected void onDestroy () {super. onDestroy (); if (bMapManager! = Null) {bMapManager. destroy (); bMapManager = null ;}@override protected void onResume () {super. onResume (); if (bMapManager! = Null) {bMapManager. start () ;}@ Override protected void onPause () {super. onPause (); if (bMapManager! = Null) {bMapManager. stop () ;}@ Override protected boolean isRouteDisplayed () {// TODO Auto-generated method stub return false;} @ Override public boolean onCreateOptionsMenu (Menu menu) {// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater (). inflate (R. menu. main, menu); return true ;}}