private void initView() { mapView = (MapView) findViewById(R.id.see_location_mapview); toolBarView = (ToolBarView) findViewById(R.id.see_location_toolbar); toolBarView.setBackButtonImage(R.mipmap.icon_back); toolBarView.setBackButtonVisible(true); toolBarView.setBackButtonOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); toolBarView.setTitleText("查看接单人位置"); baiduMap = mapView.getMap(); MapStatusUpdate update = MapStatusUpdateFactory.zoomTo(19f); baiduMap.setMapStatus(update); handler = new MyHandler(this); }
private void moveToMe(BDLocation location) { MapStatusUpdate mapUpdate=MapStatusUpdateFactory.zoomTo(18); baiduMap.setMapStatus(mapUpdate); //开始移动 MapStatusUpdate mapLatlng=MapStatusUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude())); baiduMap.setMapStatus(mapLatlng); //显示我的位置 MyLocationData.Builder locationBuilder=new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData=locationBuilder.build(); baiduMap.setMyLocationData(locationData); //显示用户所在地附近 Toast.makeText(this,"您当前在"+location.getAddrStr()+"附近",Toast.LENGTH_SHORT).show(); }
private void initMapSetting() { mMapView.showZoomControls(false); mBaiduMap = mMapView.getMap(); // 开启定位图层 mBaiduMap.setMyLocationEnabled(true); //设置指南针 // UiSettings uiSettings = mBaiduMap.getUiSettings(); // uiSettings.setCompassEnabled(true); mBaiduMap.setCompassPosition(new Point(660,60)); //设置普通地图 mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); //设置定位图层配置信息,只有先允许定位图层后设置定位图层配置信息才会生效 mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( MyLocationConfiguration.LocationMode.NORMAL, false, null)); mBaiduMap.setBuildingsEnabled(false); //设置缩放级别 MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(16.0f); mBaiduMap.setMapStatus(msu); }
/** * iniMap 初始化地图 */ private void iniMap() { LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(3000); mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; // 缩放 MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(14.0f); mBaiduMap.setMapStatus(msu); mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); mLocClient.setLocOption(option); mLocClient.start(); initOverlay(); // 开启线程,一直修改GPS坐标 LocationUtil.startLocaton(); }
public void navigateTo(BDLocation location){ if(isFirstLocate){ LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude()); showToast("定位到当前位置已执行"); MapStatusUpdate update=MapStatusUpdateFactory.zoomTo(8f); baiduMap.animateMapStatus(update); update= MapStatusUpdateFactory.newLatLng(latLng); baiduMap.animateMapStatus(update); isFirstLocate=false; } MyLocationData.Builder locationBuilder=new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); baiduMap.setMyLocationData(locationBuilder.build()); }
@Override public void onReceiveLocation(BDLocation bdLocation) { mLastLocationData=bdLocation; MyLocationData myLocationData=new MyLocationData.Builder() .accuracy(bdLocation.getRadius()) .latitude(bdLocation.getLatitude()) .longitude(bdLocation.getLongitude()) .build(); mBaiduMap.setMyLocationData(myLocationData); MapStatusUpdate msu1 = MapStatusUpdateFactory.zoomTo(15.0f); mBaiduMap.setMapStatus(msu1); if(isFirstIn){ LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude()); MapStatusUpdate msu=MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.setMapStatus(msu); isFirstIn=false; } }
public void onMapStatusChangeFinish(MapStatus mapStatus) { String _str = mapStatus.toString(); String _regex = "target lat: (.*)\ntarget lng"; String _regex2 = "target lng: (.*)\ntarget screen x"; changeLatitude = Double.parseDouble(latlng(_regex, _str)); changeLongitude = Double.parseDouble(latlng(_regex2, _str)); LatLng changeLL = new LatLng(changeLatitude, changeLongitude); startNodeStr = PlanNode.withLocation(changeLL); Log.d(TAG, "changeLatitude-----change--------" + changeLatitude); Log.d(TAG, "changeLongitude-----change--------" + changeLongitude); if (!isNeedCurrentlocation) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(changeLL); baiduMap.setMapStatus(u); if (Math.hypot((changeLatitude - currentLatitude), (changeLongitude - currentLongitude)) > 0.00001) { Logger.d(Math.hypot((changeLatitude - currentLatitude), (changeLongitude - currentLongitude))); if (routeOverlay != null) routeOverlay.removeFromMap(); addOverLayout(changeLatitude, changeLongitude); } } }
/** * des:地图跳到指定位置 * * @param location */ private void navigateTo(BDLocation location) { if (isFirstLocation) { LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll); baiduMap.animateMapStatus(update); update = MapStatusUpdateFactory.zoomTo(18f); baiduMap.animateMapStatus(update); isFirstLocation = false; } MyLocationData.Builder builder = new MyLocationData.Builder(); builder.latitude(location.getLatitude()); builder.longitude(location.getLongitude()); MyLocationData data = builder.build(); baiduMap.setMyLocationData(data); }
private void initViews() { mBtnPre = (Button) findViewById(R.id.btn_busline_pre); mBtnNext = (Button) findViewById(R.id.btn_busline_next); mBtnPre.setVisibility(View.INVISIBLE); mBtnNext.setVisibility(View.INVISIBLE); etRouteOnline = (EditText) findViewById(R.id.et_route_online); mBaiduMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.bmapView)).getBaiduMap(); // �趨��ͼ��ʼ���ĵ����꣨�����ʵ��ѧ����У���� LatLng xayd = new LatLng(34.162719, 108.907775); // �趨��ͼ״̬���趨��ʼ���ĵ�����ż����� MapStatus mMapStatus = new MapStatus.Builder().target(xayd).zoom(12) .build(); // ����MapStatusUpdate�����Ա�������ͼ״̬��Ҫ�����ı仯 MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory .newMapStatus(mMapStatus); // ���õ�ͼ״̬ mBaiduMap.setMapStatus(mMapStatusUpdate); }
private void initBaiduMap() { mBaiduMap = mIMapView.getBaiduMap(); //获取地图对象控制器 mBaiduMap.setBuildingsEnabled(true);//设置显示楼体 mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(19f));//设置地图状态 mUiSettings = mBaiduMap.getUiSettings(); mUiSettings.setZoomGesturesEnabled(true); mUiSettings.setScrollGesturesEnabled(true); mUiSettings.setRotateGesturesEnabled(true); mUiSettings.setOverlookingGesturesEnabled(true); mUiSettings.setCompassEnabled(true); MapStatus ms = new MapStatus.Builder().overlook(30).build(); MapStatusUpdate u = MapStatusUpdateFactory.newMapStatus(ms); mBaiduMap.animateMapStatus(u, 1000); // 初始化搜索模块 mSearch = GeoCoder.newInstance(); mSearch.setOnGetGeoCodeResultListener(this); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, container, false); // Inflate the layout for this fragment switchLocation = (Switch) view.findViewById(R.id.switchLocation); switchLBSTrace = (Switch) view.findViewById(R.id.switchLBSTrace); switchLocation.setOnCheckedChangeListener(this); switchLBSTrace.setOnCheckedChangeListener(this); mMapView = (TextureMapView) view.findViewById(R.id.bmapView); baiduMap = mMapView.getMap(); baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null)); application.setMaxZoomLevel(baiduMap.getMaxZoomLevel()); // 开启定位图层 baiduMap.setMyLocationEnabled(true); baiduMap.setOnMarkerClickListener(this); //再次进入地图fragment时界面刷新 if (application.latLng != null) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2); baiduMap.animateMapStatus(u);//动画移动摄像头 if (radarNearbyInfoList != null) { refreshMapUI(); } } return view; }
@Override public boolean onMarkerClick(Marker marker) { Log.d("lml", "MapFragment:覆盖物被点击"); baiduMap.hideInfoWindow(); if (marker != null) { latLngshow = marker.getPosition(); reverseGeoCodeOption.location(latLngshow); geoCoder.reverseGeoCode(reverseGeoCodeOption); tvAddOverlayGeoCoder.setText("正在获取详细位置"); bundle = marker.getExtraInfo(); generalIsMale = bundle.getString("general").equals("m"); layoutAddOverlayRadarNearbyItem.setBackgroundColor(getResources().getColor(generalIsMale ? R.color.blue : R.color.pink)); imageViewAddOverlayItem.setImageResource(generalIsMale ? R.mipmap.map_portrait_man : R.mipmap.map_portrait_woman); tvAddOverlayItemUserID.setText(bundle.getString("userID")); tvAddOverlayItemDistance.setText("距离" + bundle.getInt("distance") + "米 "); tvAddOverlayItemLatlng.setText("坐标: " + latLngshow.latitude + " , " + latLngshow.longitude + " "); Log.d("lml", "MapFragment显示的信息:" + bundle.getString("userID")); Log.d("lml", bundle.getString("general") + ";" + generalIsMale); baiduMap.showInfoWindow(new InfoWindow(viewOverlayItem, marker.getPosition(), -70)); MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(marker.getPosition()); baiduMap.animateMapStatus(update); return true; } else return false; }
private void updateBDMapStatus(BDLocation location) { final BaiduMap map = getBaiduMap(); final BaiduMapPrefFragment provider = (BaiduMapPrefFragment)(getProvider().getMapProviderPreferences()); final Context context = getActivity().getApplicationContext(); int mapType = provider.getMapType(context); map.setMapType(mapType); MyLocationData locData = new MyLocationData.Builder() .accuracy(location.getRadius()) .latitude(location.getLatitude()) .longitude(location.getLongitude()).build(); map.setMyLocationData(locData); LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); map.animateMapStatus(u); }
/** * 添加覆盖物 */ protected void addMarker() { if(null != mapStatusUpdate){ MapStatusUpdate ms = MapStatusUpdateFactory.zoomTo(19); mBaiduMap.setMapStatus(mapStatusUpdate); mBaiduMap.animateMapStatus(ms); Log.i(MainActivity.TAG, "zoom level = "+ mBaiduMap.getMaxZoomLevel()); } if(null != startMarker){ mBaiduMap.addOverlay(startMarker); } if(null != endMarker){ mBaiduMap.addOverlay(endMarker); } if(null != polylineOptions){ mBaiduMap.addOverlay(polylineOptions); } }
/** * 初始化地图 */ private void initMapView() { //设定中心点坐标 myLatLng = new LatLng(Const.LATITUDE_OF_MY_LOCATION,Const.LONGITUDE_OF_MY_LOCATION); //定义地图状态 MapStatus mMapStatus = new MapStatus.Builder() .target(myLatLng) .zoom(18) .build(); //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化 bd = BitmapDescriptorFactory .fromResource(R.drawable.icon_gcoding); MarkerOptions markerOptions = new MarkerOptions().position(myLatLng).icon(bd); mBaiduMap.addOverlay(markerOptions); MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus); //改变地图状态 mBaiduMap.setMapStatus(mMapStatusUpdate); }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data2 = new MyLocationData.Builder() .accuracy(location.getRadius())//精度 .latitude(location.getLatitude())//纬度 .longitude(location.getLongitude()).build();//经度 mBaidumap.setMyLocationData(data2); //第三个参数设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration(null, true, null); mBaidumap.setMyLocationConfigeration(config); //更新经纬度 mLatitude = location.getLatitude(); mLongtitude = location.getLongitude(); if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mBaidumap.animateMapStatus(msu); isFirstIn = false; } }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder() .direction(100)//方向 .accuracy(location.getRadius())//精度 .latitude(location.getLatitude())//纬度 .longitude(location.getLongitude()).build();//经度 mBaiduMap.setMyLocationData(data); MyLocationConfiguration config = new MyLocationConfiguration(null, true, null); mBaiduMap.setMyLocationConfigeration(config); //更新经纬度 mLatitude = location.getLatitude(); mLongtitude = location.getLongitude(); if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mBaiduMap.animateMapStatus(msu); isFirstIn = false; } }
private void initView() { mMapView = (MapView) findViewById(R.id.id_bmapView); mBaiduMap = mMapView.getMap(); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);//缩放等级17=100m mBaiduMap.setMapStatus(msu); mLocationMode = MyLocationConfiguration.LocationMode.NORMAL; //隐藏缩放控件和百度logo int childCount = mMapView.getChildCount(); for (int i = 0; i < childCount; i++) { View child = mMapView.getChildAt(i); if (child instanceof ZoomControls || child instanceof ImageView) { child.setVisibility(View.GONE); } } //改变比例尺的位置 final int screenheight = this.getWindowManager().getDefaultDisplay().getHeight(); mBaiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { mMapView.setScaleControlPosition(new Point(200, screenheight - 307)); } }); }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder() .direction(mCurrentX)//更新当前方向 .accuracy(400.0f)//精度 .latitude(location.getLatitude())//纬度 .longitude(location.getLongitude()).build();//经度 mBaiduMap.setMyLocationData(data); //可在第三个参数设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration(mLocationMode, true, null); mBaiduMap.setMyLocationConfigeration(config); //更新经纬度 mLatitude = location.getLatitude(); mLongtitude = location.getLongitude(); mCity = location.getCity(); if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mBaiduMap.animateMapStatus(msu); isFirstIn = false; Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_SHORT).show(); } }
private void initView() { mBtnPre = (Button) findViewById(R.id.pre); mBtnNext = (Button) findViewById(R.id.next); mBtnPre.setVisibility(View.INVISIBLE); mBtnNext.setVisibility(View.INVISIBLE); busSearchView = findViewById(R.id.bus_searchView); mBaiduMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.bmapView)).getBaiduMap(); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(16.0f);//缩放等级16=200m mBaiduMap.setMapStatus(msu); mlocationClient = new LocationClient(this); mLocationListener = new MyLocationListener(); mlocationClient.registerLocationListener(mLocationListener); LocationClientOption option = new LocationClientOption(); option.setCoorType("bd09ll"); option.setIsNeedAddress(true); option.setOpenGps(true); option.setScanSpan(1000); mlocationClient.setLocOption(option); }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder() .accuracy(location.getRadius())//精度 .latitude(location.getLatitude())//纬度 .longitude(location.getLongitude()).build();//经度 mBaiduMap.setMyLocationData(data); //可在第三个参数设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration(null, true, null); mBaiduMap.setMyLocationConfigeration(config); //更新经纬度 mLatitude = location.getLatitude(); mLongtitude = location.getLongitude(); if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mBaiduMap.animateMapStatus(msu); isFirstIn = false; } }
@Override protected void initViews() { SDKInitializer.initialize(getApplicationContext()); setContentView(R.layout.activity_hospital_periphery_navigation); setTitleBack("周边商户"); rbDrug = (RadioButton) findViewById(R.id.rb_drug); rbHotel = (RadioButton) findViewById(R.id.rb_hotel); rbBank = (RadioButton) findViewById(R.id.rb_bank); rbIce = (RadioButton) findViewById(R.id.rb_ice); mMapView = (MapView) findViewById(R.id.mv); mBaiduMap = mMapView.getMap(); //普通地图 mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); //设定中心点坐标 LatLng centerPoint = new LatLng(31.3023280000, 120.5906890000); //定义地图状态 MapStatus mMapStatus = new MapStatus.Builder() .target(centerPoint) .zoom(18) .build(); //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化 MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus); //改变地图状态 mBaiduMap.setMapStatus(mMapStatusUpdate); }
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()) .longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc) { isFirstLoc = false; LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); } }
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()) .longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc) { isFirstLoc = false; LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // StringBuffer U = new StringBuffer(256); // U.append(location.getLatitude()); // U.append(location.getLongitude()); } }
@Override public void onReceiveLocation(BDLocation location) { // map view ��ٺ��ڴ����½��յ�λ�� if (location == null || mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .accuracy(location.getRadius()) // �˴����ÿ�����ȡ���ķ�����Ϣ��˳ʱ��0-360 .direction(100).latitude(location.getLatitude()) .longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); if(isFirstLoc){ isFirstLoc = false; LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); setImmerseLayout(findViewById(R.id.map_layout)); instance = this; init(); mLocationClient = new LocationClient(getApplicationContext()); // 声明LocationClient类 initLocation(); mLocationClient.start(); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(maxZoom); mBaiduMap.setMapStatus(msu); mBaiduMap.setMyLocationEnabled(true); mBaiduMap.setOnMapClickListener(this); mBaiduMap.setOnMapStatusChangeListener(this); initMarkerClickEvent(); }
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; curMapCenterLatLng = mBaiduMap.getMapStatus().target; mCurrentLantitude = location.getLatitude(); mCurrentLongitude = location.getLongitude(); curCity = location.getCity(); textView_curCity.setText(curCity); MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(mCurrentLantitude).longitude(mCurrentLongitude).build(); // 设置定位数据 mBaiduMap.setMyLocationData(locData); if (isFirstLoc) { isFirstLoc = false; LatLng ll = new LatLng(mCurrentLantitude, mCurrentLongitude); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); getData(); } }
@Override public void onClick(View v) { // TODO 自动生成的方法存根 switch (v.getId()) { case R.id.map_imageView_mylocaiton: LatLng ll = new LatLng(mCurrentLantitude, mCurrentLongitude); // float zoom = mBaiduMap.getMapStatus().zoom; // // showCurrtenStroeOnMap(ll, zoom); System.out.println("点击定位:" + ll); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); Utity.showToast(getApplicationContext(), "正在定位中..."); break; case R.id.map_layout_store: Bundle pBundle = new Bundle(); pBundle.putString("fromFlag", "map"); pBundle.putSerializable("list", (Serializable) list); openActivity(ShopListActivity.class, pBundle); break; } }
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; MyLocationData locData = new MyLocationData.Builder() .accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()) .longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc) { isFirstLoc = false; lat = location.getLatitude(); lng = location.getLongitude(); LatLng ll = new LatLng(lat, lng); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); } }
private void navigateTo(BDLocation location){ if (isFirstLocate){ LatLng ll=new LatLng(location.getLatitude(),location.getLongitude()); MapStatusUpdate mapStatus=MapStatusUpdateFactory.newLatLngZoom(ll,16f); baiduMap.setMapStatus(mapStatus); isFirstLocate=false; } MyLocationData.Builder locationBuilder=new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData=locationBuilder.build(); baiduMap.setMyLocationData(locationData); }
private void initView() { // 获取地图控件引用 mMapView = (MapView) findViewById(R.id.bmapView); mbaiduMap = mMapView.getMap(); // 设置地图放大缩小参数 MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f); mbaiduMap.setMapStatus(msu); }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder()// 经度 .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); //设置我的定位 mbaiduMap.setMyLocationData(data); //取出经纬度 mLatitude = location.getLatitude(); mLongitude = location.getLongitude(); //是否是第一次定位 if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); // 设置经纬度 MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mbaiduMap.animateMapStatus(msu); isFirstIn = false; } Toast.makeText( context, "定位成功:纬度" + location.getLatitude() + "经度:" + location.getLongitude() + "地址是:" + location.getAddrStr() + "城市是:" + location.getCity(), Toast.LENGTH_SHORT).show(); }
private void showMap(double latitude, double longtitude, String address) { sendButton.setVisibility(View.GONE); LatLng llA = new LatLng(latitude, longtitude); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
/** * setCurrentMapLatLng 设置当前坐标 */ public static void setCurrentMapLatLng(LatLng arg0) { curLatlng = arg0; mMarker.setPosition(arg0); // 设置地图中心点为这是位置 LatLng ll = new LatLng(arg0.latitude, arg0.longitude); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 根据经纬度坐标 找到实地信息,会在接口onGetReverseGeoCodeResult中呈现结果 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(arg0)); }
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder()// .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mbaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( locationmode, true, mIconLocation); mbaiduMap.setMyLocationConfigeration(config); // 获取经度、纬度 mLongitude = location.getLongitude(); mLatitude = location.getLatitude(); // 当前的位置为开始位置。 mStartLocation = new LatLng(location.getLatitude(), location.getLongitude()); if (isFirstIn) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); mbaiduMap.animateMapStatus(msu); isFirstIn = false; Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_LONG).show(); } }
private void initView() { // 获取地图控件引用 mMapView = (MapView) findViewById(R.id.bmapView); mbaiduMap = mMapView.getMap(); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f); mbaiduMap.setMapStatus(msu); list = new ArrayList<Marker>(); }