关于Android高德地图的简单开发实例代码(DEMO)
废话不多说了,直接给大家上干货了。
以下为初次接触时,练手的DEMO
importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.ContentValues; importandroid.database.Cursor; importandroid.database.SQLException; importandroid.database.sqlite.SQLiteDatabase; importandroid.graphics.Color; importandroid.os.Bundle; importandroid.os.Handler; importandroid.os.Message; importandroid.text.Editable; importandroid.text.TextWatcher; importandroid.util.Log; importandroid.view.Gravity; importandroid.view.KeyEvent; importandroid.view.View; importandroid.widget.AdapterView; importandroid.widget.AutoCompleteTextView; importandroid.widget.Button; importandroid.widget.LinearLayout; importandroid.widget.ListView; importandroid.widget.SimpleAdapter; importandroid.widget.TextView; importandroid.widget.Toast; importcom.amap.api.location.AMapLocation; importcom.amap.api.location.AMapLocationClient; importcom.amap.api.location.AMapLocationClientOption; importcom.amap.api.location.AMapLocationListener; importcom.amap.api.maps.AMap; importcom.amap.api.maps.CameraUpdateFactory; importcom.amap.api.maps.LocationSource; importcom.amap.api.maps.MapView; importcom.amap.api.maps.UiSettings; importcom.amap.api.maps.model.BitmapDescriptorFactory; importcom.amap.api.maps.model.LatLng; importcom.amap.api.maps.model.Marker; importcom.amap.api.maps.model.MarkerOptions; importcom.amap.api.maps.model.Poi; importcom.amap.api.maps.overlay.PoiOverlay; importcom.amap.api.services.core.LatLonPoint; importcom.amap.api.services.core.PoiItem; importcom.amap.api.services.core.SuggestionCity; importcom.amap.api.services.geocoder.GeocodeQuery; importcom.amap.api.services.geocoder.GeocodeResult; importcom.amap.api.services.geocoder.GeocodeSearch; importcom.amap.api.services.geocoder.RegeocodeQuery; importcom.amap.api.services.geocoder.RegeocodeResult; importcom.amap.api.services.help.Inputtips; importcom.amap.api.services.help.InputtipsQuery; importcom.amap.api.services.help.Tip; importcom.amap.api.services.poisearch.PoiResult; importcom.amap.api.services.poisearch.PoiSearch; importjava.util.ArrayList; importjava.util.HashMap; importjava.util.List; importjava.util.Map; publicclassBaseMapActivityextendsActivityimplements View.OnClickListener,LocationSource,AMapLocationListener,TextWatcher,Inputtips.InputtipsLi stener,AMap.OnMarkerClickListener,PoiSearch.OnPoiSearchListener,AMap.OnPOIClickListener,Ge ocodeSearch.OnGeocodeSearchListener{ privateMapViewmapView; privateAMapaMap; privateLinearLayoutly_1; privateButtonbt_map; privateAutoCompleteTextViewsearch_keyword;//输入要搜索的keyword privateListViewlistview;//keyword监听数据形成的列表 privateProgressDialogprogDialog=null;//进度条显示 privateLinearLayoutly_2;//ly_1所包含的布局之一 privateButtonbt_back1; privateListViewhistory_listview; privateTextViewhistory_item_tv; List<Map<String,Object>>listItem;//输入keyword,数据返回的list数据源 //====================以下为操作数据库================== privateArrayList<HashMap<String,Object>>MapHistoryList; //=============地图定位控件============== privateOnLocationChangedListenermListener; privateAMapLocationClientmlocationClient; privateAMapLocationClientOptionmLocationOption; //=============地图自身UI定义============ privateUiSettingsmUiSettings; //=============通用地图控件============== privateLatLonPointmLatLonPoint;//初始定位经纬度 privatedoublems,me;//经纬度double值 privateStringlocationAdressName; //=============地图POI关键字搜索========== privatePoiResultpoiResult;//poi返回的结果 privatePoiSearch.Queryquery;//Poi查询条件类 privatePoiSearchpoiSearch;//POI搜索 privatestaticStringkeyWord="";//要输入的poi搜索关键字 privateintcurrentPage=0;//当前页面,从0开始计数 privateButtonbt_search;//搜索POI privateMarkerOptionsoptions; //========================以下为地理编码================= privateGeocodeSearchgeocoderSearch; privatestaticStringaddressCityDistric;//得到逆地理编码的市区 @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.base_map_activity); mapView=(MapView)findViewById(R.id.map); mapView.onCreate(savedInstanceState);//此方法必须重写 init(); initUi(); initHistoryList(); } /** *初始化AMap对象 */ privatevoidinit(){ if(aMap==null){ aMap=mapView.getMap(); setUpMap(); } } /** *设置一些amap的属性 */ privatevoidsetUpMap(){ aMap.setLocationSource(this);//设置定位监听 aMap.getUiSettings().setMyLocationButtonEnabled(true);//设置默认定位按钮是否显示 aMap.setMyLocationEnabled(true);//设置为true表示显示定位层并可触发定位,false表示 隐藏定位层并不可触发定位,默认是false //设置定位的类型为定位模式,可以由定位、跟随或地图根据面向方向旋转几种 aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newLatLng(me,ms),14));//当前 地图镜头界面(让地图在刚进入时就是这个的话,需要先得到LatLng值即可,待后续修正) mUiSettings=aMap.getUiSettings();//实例化地图UI设置 mUiSettings.setScaleControlsEnabled(true);//比例尺显示 mUiSettings.setCompassEnabled(false);//指南针不显示 mLocationOption.setGpsFirst(true);//优先返回GPS定位信息 aMap.setOnPOIClickListener(this);//POI点击事件监听 aMap.setOnMarkerClickListener(this); geocoderSearch=newGeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this);//注册地理编码监听 } privatevoidinitUi(){ ly_1=(LinearLayout)findViewById(R.id.map_2);//地图隐藏掉显示的界面 bt_map=(Button)findViewById(R.id.map_bt);//首页按钮 bt_map.setOnClickListener(this); //返回键 bt_back1=(Button)findViewById(R.id.bt_back_1); bt_back1.setOnClickListener(this); //keyword search_keyword=(AutoCompleteTextView)findViewById(R.id.keyWord); search_keyword.addTextChangedListener(this); //keyword输入list listview=(ListView)findViewById(R.id.map_list); //第二页显示 ly_2=(LinearLayout)findViewById(R.id.history_record); //POI搜索按钮 bt_search=(Button)findViewById(R.id.bt_search); bt_search.setOnClickListener(this); //历史记录list history_listview=(ListView)findViewById(R.id.lv_history); history_item_tv=(TextView)findViewById(R.id.history_item_addressName); } @Override publicvoidonClick(Viewv){ switch(v.getId()){ caseR.id.map_bt: bt_map.setVisibility(View.GONE); mapView.setVisibility(View.GONE); ly_1.setVisibility(View.VISIBLE); break; caseR.id.bt_search: //mlocationClient.stopLocation(); searchButton(); bt_map.setVisibility(View.GONE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); ly_2.setVisibility(View.GONE); break; caseR.id.bt_back_1: aMap.clear(); bt_map.setVisibility(View.VISIBLE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.GONE); break; } } /** *方法必须重写 */ @Override protectedvoidonResume(){ super.onResume(); mapView.onResume(); } /** *方法必须重写 */ @Override protectedvoidonPause(){ super.onPause(); mapView.onPause(); } /** *方法必须重写 */ @Override protectedvoidonSaveInstanceState(BundleoutState){ super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } /** *方法必须重写 */ @Override protectedvoidonDestroy(){ super.onDestroy(); mapView.onDestroy(); } /** *back设置 *@paramkeyCode *@paramevent *@return */ @Override publicbooleanonKeyDown(intkeyCode,KeyEventevent){ if(keyCode==KeyEvent.KEYCODE_BACK) { aMap.clear(); bt_map.setVisibility(View.VISIBLE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.GONE); } returnfalse; } //========================================================以下为定位 =============================================== /** *激活定位 */ @Override publicvoidactivate(OnLocationChangedListenerlistener){ mListener=listener; if(mlocationClient==null){ mlocationClient=newAMapLocationClient(this); mLocationOption=newAMapLocationClientOption(); //设置定位监听 mlocationClient.setLocationListener(this); //设置为高精度定位模式 mLocationOption.setLocationMode (AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //设置定位参数 mlocationClient.setLocationOption(mLocationOption); //此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗, //注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用 stopLocation()方法来取消定位请求 //在定位结束后,在合适的生命周期调用onDestroy()方法 //在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求, 定位sdk内部会移除 mlocationClient.startLocation(); } } /** *停止定位 */ @Override publicvoiddeactivate(){ mListener=null; if(mlocationClient!=null){ mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient=null; } /** *定位成功后回调函数 */ @Override publicvoidonLocationChanged(AMapLocationamapLocation){ if(mListener!=null&&amapLocation!=null){ if(amapLocation!=null &&amapLocation.getErrorCode()==0){ mListener.onLocationChanged(amapLocation);//显示系统小蓝点 Messagemsg=mHandler.obtainMessage();//定位成功后,开始hangler更新经纬 度 msg.obj=amapLocation; msg.what=Utils.MSG_LOCATION_FINISH; mHandler.sendMessage(msg); //当前定位后的详细位置(省、市、区、街道信息) locationAdressName=amapLocation.getProvider()+amapLocation.getCity ()+amapLocation.getDistrict()+amapLocation.getAddress(); }else{ StringerrText="定位失败,"+amapLocation.getErrorCode()+":"+ amapLocation.getErrorInfo(); Toast.makeText(getApplicationContext(),errText,Toast.LENGTH_SHORT).show(); } } } HandlermHandler=newHandler(){ publicvoiddispatchMessage(android.os.Messagemsg){ switch(msg.what){ //开始定位 caseUtils.MSG_LOCATION_START: //("正在定位..."); break; //定位完成 caseUtils.MSG_LOCATION_FINISH: AMapLocationloc=(AMapLocation)msg.obj; Stringresult=Utils.getLocationStr(loc); //(result); ms=Utils.jingdu; me=Utils.weidu; mLatLonPoint=newLatLonPoint(me,ms); break; //停止定位 caseUtils.MSG_LOCATION_STOP: //("定位停止"); break; default: break; } }; }; //=========================================以下为keyword改变监听 =================================== @Override publicvoidbeforeTextChanged(CharSequencecharSequence,inti,inti1,inti2){ } @Override publicvoidonTextChanged(CharSequences,intstart,intstop,intcount){ StringnewText=s.toString().trim(); //在这里判断是否有输入 if(s.length()<1){ ly_2.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); }else { ly_2.setVisibility(View.GONE); mapView.setVisibility(View.GONE); listview.setVisibility(View.VISIBLE); } if(!AMapUtil.IsEmptyOrNullString(newText)){ InputtipsQueryinputquery=newInputtipsQuery(newText,Utils.city); InputtipsinputTips=newInputtips(BaseMapActivity.this,inputquery); inputTips.setInputtipsListener(this);//设置=======得到数据监听======= inputTips.requestInputtipsAsyn(); } } @Override publicvoidafterTextChanged(Editableeditable){ } //=======得到数据监听======= @Override publicvoidonGetInputtips(List<Tip>tipList,intrCode){ if(rCode==1000){//正确返回 //监听反馈回来的数据当做listView数据源 listItem=newArrayList<Map<String,Object>>(); for(inti=0;i<tipList.size();i++){ HashMap<String,Object>map=newHashMap<String,Object>(); map.put("mapName",tipList.get(i).getName()); map.put("mapAddress",tipList.get(i).getDistrict()); map.put("mapPosition",tipList.get(i).getPoint()); listItem.add(map); } listview.setAdapter(newMapListAdapter(this,listItem)); //输入时keyword产生的列表的item点击事件 listview.setOnItemClickListener(newAdapterView.OnItemClickListener(){ @Override publicvoidonItemClick(AdapterView<?>adapterView,Viewview,inti,long l){ aMap.clear(); mlocationClient.stopLocation(); LatLonPointlatLonPoint=(LatLonPoint)(listItem.get(i).get ("mapPosition")); Doubledd=latLonPoint.getLatitude(); Doubleee=latLonPoint.getLongitude(); options=newMarkerOptions(); Markermarker=aMap.addMarker(options.position(newLatLng(dd,ee)));// 做marker标记 marker.setVisible(true); aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(newLatLng(dd,ee), 14));//移动视图 bt_map.setVisibility(View.GONE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); ly_2.setVisibility(View.GONE); Toast.makeText(getApplicationContext(),""+listItem.get(i).get ("mapPosition"),Toast.LENGTH_SHORT).show(); } }); }else{ ToastUtil.showerror(this,rCode); } } //==========================================以下为POI关键字搜索 ===================================================== /** *显示进度框 */ privatevoidshowProgressDialog(){ if(progDialog==null) progDialog=newProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setIndeterminate(false); progDialog.setCancelable(false); progDialog.setMessage("正在搜索:\n"+keyWord); progDialog.show(); } /** *隐藏进度框 */ privatevoiddissmissProgressDialog(){ if(progDialog!=null){ progDialog.dismiss(); } } /** *点击搜索按钮 */ publicvoidsearchButton(){ keyWord=AMapUtil.checkEditText(search_keyword); if("".equals(keyWord)){ ToastUtil.show(BaseMapActivity.this,"请输入搜索关键字"); return; }else{ doSearchQuery(); if(MapHistoryList.size()>0){ for(inti=0;i<MapHistoryList.size();i++){ if(keyWord.equals(MapHistoryList.get(i).get("mapHistoryName").toString ())){ return; } }} map_addToHistory();//增加数据到数据库 } } /** *开始进行poi搜索 */ protectedvoiddoSearchQuery(){ showProgressDialog();//显示进度框 mlocationClient.stopLocation();//停止定位20160812 query=newPoiSearch.Query(keyWord,"",Utils.city);//第一个参数表示搜索字符串第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国) query.setPageSize(20);//设置每页最多返回多少条poiitem query.setPageNum(currentPage);//设置查第一页 poiSearch=newPoiSearch(this,query); poiSearch.setOnPoiSearchListener(this); poiSearch.searchPOIAsyn(); } /** *poi没有搜索到数据,返回一些推荐城市的信息 */ privatevoidshowSuggestCity(List<SuggestionCity>cities){ Stringinfomation="推荐城市\n"; for(inti=0;i<cities.size();i++){ infomation+="城市名称:"+cities.get(i).getCityName()+"城市区号:" +cities.get(i).getCityCode()+"城市编码:" +cities.get(i).getAdCode()+"\n"; } ToastUtil.show(BaseMapActivity.this,infomation); } /** *POI信息查询回调方法 */ @Override publicvoidonPoiSearched(PoiResultresult,intrCode){ dissmissProgressDialog();//隐藏对话框 if(rCode==1000){ if(result!=null&&result.getQuery()!=null){//搜索poi的结果 if(result.getQuery().equals(query)){//是否是同一条 poiResult=result; //取得搜索到的poiitems有多少页 List<PoiItem>poiItems=poiResult.getPois();//取得第一页的poiitem数据,页数从数字0开始 List<SuggestionCity>suggestionCities=poiResult .getSearchSuggestionCitys();//当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息 if(poiItems!=null&&poiItems.size()>0){ aMap.clear();//清理之前的图标 PoiOverlaypoiOverlay=newPoiOverlay(aMap,poiItems); poiOverlay.removeFromMap(); poiOverlay.addToMap(); poiOverlay.zoomToSpan(); }elseif(suggestionCities!=null &&suggestionCities.size()>0){ showSuggestCity(suggestionCities); }else{ ToastUtil.show(BaseMapActivity.this, "无返回结果"); } } }else{ ToastUtil.show(BaseMapActivity.this, "无返回结果"); } }else{ ToastUtil.showerror(this,rCode); } } @Override publicvoidonPoiItemSearched(PoiItempoiItem,inti){ } //===================以下为POI点击事件================ @Override publicvoidonPOIClick(Poipoi){ //aMap.clear();//暂时去掉 MarkerOptionsmarkOptiopns=newMarkerOptions(); markOptiopns.position(poi.getCoordinate()); TextViewtextView=newTextView(getApplicationContext()); textView.setText("到"+poi.getName()+"去"); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.BLACK); textView.setBackgroundResource(R.drawable.dir1); markOptiopns.icon(BitmapDescriptorFactory.fromView(textView)); markOptiopns.icon(BitmapDescriptorFactory.defaultMarker()); aMap.addMarker(markOptiopns); LatLngnewLatLng=poi.getCoordinate(); Doubless=newLatLng.latitude; Doublese=newLatLng.longitude; //LatLonPointnewLatLonPoint=newLatLonPoint(ss,se); getAddress(newLatLonPoint(ss,se)); //Toast.makeText(getApplicationContext (),"marker"+addressCityDistric,Toast.LENGTH_SHORT).show(); } //==================以下为marker点击事件反馈=================== @Override publicbooleanonMarkerClick(Markermarker){ Toast.makeText(getApplicationContext(),"marker点击"+marker.getPosition ()+"--"+marker.getTitle()+"--"+marker.getSnippet(),Toast.LENGTH_SHORT).show(); marker.getPosition(); returnfalse; } //========================以下为地理编码以及你地理编码================================ /** *响应地理编码 */ publicvoidgetLatlon(finalStringname){ //showDialog(); GeocodeQueryquery=newGeocodeQuery(name,Utils.city);//第一个参数表示地址,第 二个参数表示查询城市,中文或者中文全拼,citycode、adcode, geocoderSearch.getFromLocationNameAsyn(query);//设置同步地理编码请求 } /** *响应逆地理编码 */ publicvoidgetAddress(finalLatLonPointlatLonPoint){ //showDialog(); RegeocodeQueryquery=newRegeocodeQuery(latLonPoint,200, GeocodeSearch.AMAP);//第一个参数表示一个Latlng,第二参数表示范围多少米, 第三个参数表示是火系坐标系还是GPS原生坐标系 geocoderSearch.getFromLocationAsyn(query);//设置同步逆地理编码请求 } /** *地理编码查询回调 */ @Override publicvoidonGeocodeSearched(GeocodeResultresult,intrCode){ //dismissDialog(); if(rCode==1000){ if(result!=null&&result.getGeocodeAddressList()!=null &&result.getGeocodeAddressList().size()>0){ //GeocodeAddressaddress=result.getGeocodeAddressList().get(0); //aMap.animateCamera(CameraUpdateFactory.newLatLngZoom( //AMapUtil.convertToLatLng(address.getLatLonPoint()),15)); //geoMarker.setPosition(AMapUtil.convertToLatLng(address //.getLatLonPoint())); //addressName="经纬度值:"+address.getLatLonPoint()+"\n位置描 述:" //+address.getFormatAddress(); } }else{ ToastUtil.showerror(this,rCode); } } /** *逆地理编码回调 */ @Override publicvoidonRegeocodeSearched(RegeocodeResultresult,intrCode){ //dismissDialog(); if(rCode==1000){ if(result!=null&&result.getRegeocodeAddress()!=null){ addressCityDistric=result.getRegeocodeAddress().getFormatAddress(); TextViewtv=(TextView)findViewById(R.id.address_name); tv.setText(addressCityDistric); Log.e("fans",""+addressCityDistric); }else{ ToastUtil.showerror(this,rCode); } } } } 资源文件如下: <?xmlversion="1.0"encoding="utf-8"?> <RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.gaodemap.BaseMapActivity"> <Button android:id="@+id/map_bt" android:layout_width="260dp" android:layout_height="40dp" android:text="|查地点、搜路线" android:layout_marginLeft="10dp" android:layout_marginTop="7dp" android:background="@android:color/white" /> <com.amap.api.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent"> </com.amap.api.maps.MapView> <LinearLayout android:id="@+id/ly_address_route" android:layout_width="350dp" android:layout_height="70dp" android:orientation="vertical" android:layout_centerHorizontal="true" android:layout_marginTop="450dp" android:background="@android:color/darker_gray" > <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal" > <TextView android:id="@+id/address_name" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center"/> <TextView android:id="@+id/xiangqing" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="3" android:text="详情" android:gravity="center" /> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black"></FrameLayout> <TextView android:id="@+id/route_tv" android:layout_width="match_parent" android:layout_height="29dp" android:text="路径规划" android:gravity="center"/> </LinearLayout> <LinearLayout android:id="@+id/map_2" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:visibility="gone"> <LinearLayout android:layout_width="match_parent" android:layout_height="60dp" android:orientation="horizontal"> <Button android:id="@+id/bt_back_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="返回"/> <AutoCompleteTextView android:id="@+id/keyWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入关键字" android:textSize="14dp" android:imeOptions="actionDone" android:inputType="text|textAutoComplete" android:maxLength="20" android:layout_weight="2"/> <Button android:id="@+id/bt_search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="搜索"/> </LinearLayout> <ListView android:id="@+id/map_list" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"></ListView> <LinearLayout android:id="@+id/history_record" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@android:color/darker_gray" > <TextView android:id="@+id/history_tv" android:layout_width="match_parent" android:layout_height="50dp" android:text="历史记录" android:textSize="16dp" android:gravity="center" /> <ListView android:id="@+id/lv_history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"></ListView> <TextView android:id="@+id/zero_history_tv" android:layout_width="match_parent" android:layout_height="50dp" android:text="清空历史记录" android:textSize="16dp" android:gravity="center" /> </LinearLayout> </LinearLayout> </RelativeLayout> 代码中相关的工具类,即官方DEMO中提供的工具类,并没什么改变。。 好了,初步的使用就是这样。 清单文件中相关权限 <!--地图相关权限--> <uses-permissionandroid:name="android.permission.INTERNET"/> <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/> <uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permissionandroid:name="android.permission.CHANGE_CONFIGURATION"/> <uses-permissionandroid:name="android.permission.WAKE_LOCK"/> <uses-permissionandroid:name="android.permission.WRITE_SETTINGS"/> <!--定位需要的服务使用2.0的定位需要加上这个--> <serviceandroid:name="com.amap.api.location.APSService"></service> 申请官方相关key,根据自己androdistudio上的sha1值和包名来获取 <meta-data android:name="com.amap.api.v2.apikey" android:value="xxxxxxxxxxxxxxxxxxxxxxx"/>
以上所述是小编给大家介绍的关于Android高德地图的简单开发实例代码(DEMO),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!