Package com. njupt. bmap_helloworld; import com. baidu. mapapi. BMapManager; import com. baidu. mapapi. geoPoint; import com. baidu. mapapi. MKGeneralListener; import com. baidu. mapapi. mapActivity; import com. baidu. mapapi. mapController; import com. baidu. mapapi. mapView; import com. baidu. mapapi. overlay; import android. OS. bundle; import android. app. activity; import android. graphics. canvas; import android. graphics. Paint; import android. graphics. point; 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 as Zoom In or out controls @ Override protected void onCreate (Bund Le 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 () ;}@ Ove Rride 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); mapView. getOverlays (). add (new MyOverLay (); // mapView. setTraffic (true); displays the traffic map // mapView. setSatellite (true); display satellite map} public class MyOverLay extends Overlay {// build location Private GeoPoint geoPoint GeoPoint = new GeoPoint (int) (39.915*1E6), (int) (116.404*1E6 )); // declare a Paint brush tool private paint Paint = new Paint (); @ Override public void draw (Canvas arg0, MapView arg1, boolean arg2) {super. draw (arg0, arg1, arg2); Point point = mapView. getProjection (). toPixels (geoPoint, null); arg0.drawText ("* Here is Tiananmen Square", point. x, point. y, paint) ;}@ Override protected void onDestroy () {super. on Destroy (); 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 ;}}