百度地圖開(kāi)發(fā)為什么運(yùn)行之后再虛擬機(jī)上顯示藍(lán)色背景,不顯示地圖com.example.administrator.test_mapandroid.graphics.Colorandroid.graphics.Pointandroid.location.Addressandroid.location.Geocoderandroid.os.Bundleandroid.support.v7.app.AppCompatActivityandroid.util.Logandroid.view.Menuandroid.view.MenuItemandroid.view.Viewandroid.widget.Buttonandroid.widget.EditTextandroid.widget.ImageViewandroid.widget.RelativeLayoutandroid.widget.TextViewandroid.widget.Toastcom.baidu.location.BDLocationcom.baidu.location.BDLocationListenercom.baidu.location.LocationClientcom.baidu.location.LocationClientOptioncom.baidu.mapapi.SDKInitializercom.baidu.mapapi.map.BaiduMapcom.baidu.mapapi.map.BitmapDescriptorcom.baidu.mapapi.map.BitmapDescriptorFactorycom.baidu.mapapi.map.InfoWindowcom.baidu.mapapi.map.MapPoicom.baidu.mapapi.map.MapStatusUpdatecom.baidu.mapapi.map.MapStatusUpdateFactorycom.baidu.mapapi.map.MapViewcom.baidu.mapapi.map.Markercom.baidu.mapapi.map.MarkerOptionscom.baidu.mapapi.map.MyLocationConfigurationcom.baidu.mapapi.map.MyLocationDatacom.baidu.mapapi.map.OverlayOptionscom.baidu.mapapi.model.LatLngjava.util.ListMainActivity?AppCompatActivity?{
????MapView?BaiduMap?LocationClient?MyLocation?=?MyLocationConfiguration.LocationMode?BitmapDescriptor?Orientation?BitmapDescriptor?RelativeLayout?Button?EditText?Geocoder?(Bundle?savedInstanceState)?{
????????.onCreate(savedInstanceState)SDKInitializer.(getApplicationContext())setContentView(R.layout.)initView()initLocation()initMarker().setOnMarkerClickListener(BaiduMap.OnMarkerClickListener()?{
????????????(Marker?marker)?{
????????????????Bundle?extra?=?marker.getExtraInfo()Info?info?=?(Info)?extra.getSerializable()ImageView?imageView?=?(ImageView)?.findViewById(R.id.)TextView?name?=?(TextView)?.findViewById(R.id.)TextView?distance?=?(TextView)?.findViewById(R.id.)TextView?zan?=?(TextView)?.findViewById(R.id.)imageView.setImageResource(info.getImageId())name.setText(info.getName())distance.setText(info.getDistance())zan.setText(info.getTotal()?+?)InfoWindow?infoWindowTextView?tv?=?TextView(MainActivity.)tv.setBackgroundResource(R.drawable.)tv.setPadding()tv.setText(info.getName())tv.setTextColor(Color.())LatLng?latLng?=?marker.getPosition()Point?p?=?.getProjection().toScreenLocation(latLng)p.-=?LatLng?ll?=?.getProjection().fromScreenLocation(p)InfoWindow.OnInfoWindowClickListener?listener?=?InfoWindow.OnInfoWindowClickListener()?{
????????????????????()?{
????????????????????????.hideInfoWindow()}
????????????????}BitmapDescriptor?bd?=?BitmapDescriptorFactory.(tv)infoWindow?=?InfoWindow(bdlllistener).showInfoWindow(infoWindow).setVisibility(View.)}
????????}).setOnMapClickListener(BaiduMap.OnMapClickListener()?{
????????????(LatLng?latLng)?{
????????????????.setVisibility(View.).hideInfoWindow()}
????????????(MapPoi?mapPoi)?{
????????????????}
????????})initSearch()}
????()?{
lat?=?lng?=?Geocoder?geo?=?Geocoder(MainActivity.){
????????????????????List<Address>?list?=?geo.getFromLocation(latlng)(list?!=?){
????????????????????????(i?=?i?<?list.size()?i?++){
????????????????????????????Address?address?=?list.get(i)}
????????????????????}
????????????????}(Exception?e){
????????????????????Log.(+?e.toString())}
????????????}
()?{
????????=?BitmapDescriptorFactory.(R.drawable.)=?(RelativeLayout)?findViewById(R.id.)}
????()?{
????????=?LocationClient()=?MyLocation().registerLocationListener()LocationClientOption?locationClientOption?=?LocationClientOption()locationClientOption.setCoorType()locationClientOption.setIsNeedAddress()locationClientOption.setOpenGps()locationClientOption.setScanSpan().setLocOption(locationClientOption)=?BitmapDescriptorFactory.(R.drawable.)=?Orientation().setOnOrientationListener(Orientation.onOrientationListener()?{
????????????(x)?{
????????????????=x}
????????})}
????()?{
????????=?(MapView)?findViewById(R.id.)=?.getMap()MapStatusUpdate?msu?=?MapStatusUpdateFactory.().setMapStatus(msu)}
????()?{
????????.onResume().onResume()}
????()?{
????????.onStart().setMyLocationEnabled()(!.isStarted())
????????????.start().start()}
????()?{
????????.onPause().onPause()}
????()?{
????????.onStop().setMyLocationEnabled().stop().stop()}
????()?{
????????.onDestroy().onDestroy()}
????(Menu?menu)?{
????????getMenuInflater().inflate(R.menu.menu).onCreateOptionsMenu(menu)}
????(MenuItem?item)?{
????????(item.getItemId()){
????????????R.id.:
????????????????.setMapType(BaiduMap.)R.id.:
????????????????.setMapType(BaiduMap.)R.id.:
????????????????(.isTrafficEnabled())
????????????????{
????????????????????.setTrafficEnabled()item.setTitle()}
????????????????{
????????????????????.setTrafficEnabled()item.setTitle()}
????????????R.id.:
????????????????????toMyLocation()R.id.:
????????????????=?MyLocationConfiguration.LocationMode.R.id.:
????????????????=?MyLocationConfiguration.LocationMode.R.id.:
????????????????=?MyLocationConfiguration.LocationMode.R.id.:
????????????????addLay(Info.)}
????????.onOptionsItemSelected(item)}
????(List<Info>?list)?{
????????.clear()LatLng?latLng?=?Marker?markers?=?OverlayOptions?overlayOptions(Info?info?:?list){
????????????latLng?=?LatLng(info.getLatitude()info.getLongitude())overlayOptions?=?MarkerOptions().position(latLng).icon().zIndex()markers?=?(Marker)?.addOverlay(overlayOptions)Bundle?bundle?=?Bundle()bundle.putSerializable(info)markers.setExtraInfo(bundle)}
????????MapStatusUpdate?mus?=?MapStatusUpdateFactory.(latLng).setMapStatus(mus)}
????()?{
????????LatLng?latLng?=?LatLng()MapStatusUpdate?mapStatusUpdate?=?MapStatusUpdateFactory.(latLng).animateMapStatus(mapStatusUpdate)}
????MyLocation?BDLocationListener?{
????????(BDLocation?bdLocation)?{
????????????MyLocationData.Builder?builder?=?MyLocationData.Builder()builder.direction()builder.latitude(bdLocation.getLatitude())builder.longitude(bdLocation.getLongitude())builder.accuracy(bdLocation.getRadius())MyLocationData?locationData?=?builder.build().setMyLocationData(locationData)MyLocationConfiguration?config?=?MyLocationConfiguration
????????????????????().setMyLocationConfigeration(config)=?bdLocation.getLatitude()=?bdLocation.getLongitude()()
????????????{
???????????????LatLng?latLng?=?LatLng(bdLocation.getLatitude()bdLocation.getLongitude())MapStatusUpdate?mapStatusUpdate?=?MapStatusUpdateFactory.(latLng).animateMapStatus(mapStatusUpdate)=?Toast.(MainActivity.bdLocation.getAddrStr()Toast.).show()}
????????}
????}
}
2 回答

dky
TA貢獻(xiàn)93條經(jīng)驗(yàn) 獲得超26個(gè)贊
哥們 ,你這代碼,,亂啊, 在真機(jī)運(yùn)行過(guò)有效么? ? 前一陣子做的一個(gè)項(xiàng)目用的百度地圖 , 建議參照百度地圖sdk的規(guī)范, ?寫的很詳細(xì)。 有一個(gè)要注意的地方 , 地圖的縮放一開(kāi)始不建議設(shè)置太高, ?比例尺不宜過(guò)小 , ?對(duì)加載會(huì)有影響,請(qǐng)采納,謝謝 。?

慕勒0953083
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
大概是因?yàn)榈哪阏鏅C(jī)是android6.0及以上的系統(tǒng),然后也因?yàn)闄?quán)限問(wèn)題,你自己檢查一下,
- 2 回答
- 0 關(guān)注
- 2210 瀏覽
添加回答
舉報(bào)
0/150
提交
取消