Description of Baidu map covering

Source: Internet
Author: User

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 ;}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.