百度地图开发为什么运行之后再虚拟机上显示蓝色背景,不显示地图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 回答
- 0 关注
- 2139 浏览
添加回答
举报
0/150
提交
取消