Java Code Examples for com.baidu.mapapi.map.MapStatus#Builder
The following examples show how to use
com.baidu.mapapi.map.MapStatus#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void setModeEDog(boolean isChecked) { if (isChecked) { if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) { mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.COMPASS, true, null)); btnLocation.setImageResource(R.drawable.ic_explore_24dp); } mIsModeEDog = true; } else { if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode == MyLocationConfiguration.LocationMode.COMPASS) { mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null)); btnLocation.setImageResource(R.drawable.ic_my_location_24dp); MapStatus.Builder builder = new MapStatus.Builder().rotate(0).overlook(90); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); } mIsModeEDog = false; } }
Example 2
Source File: BaiduMapFragment.java From BmapLite with Apache License 2.0 | 6 votes |
public void setModeEDog(boolean isChecked) { if (isChecked) { if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode != MyLocationConfiguration.LocationMode.COMPASS) { mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.COMPASS, true, null)); btnLocation.setImageResource(R.drawable.ic_explore_24dp); } mIsModeEDog = true; } else { if (null != mBaiduMap.getLocationConfiguration() && mBaiduMap.getLocationConfiguration().locationMode == MyLocationConfiguration.LocationMode.COMPASS) { mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, null)); btnLocation.setImageResource(R.drawable.ic_my_location_24dp); MapStatus.Builder builder = new MapStatus.Builder().rotate(0).overlook(90); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); } mIsModeEDog = false; } }
Example 3
Source File: AddressEditDelegate.java From FastWaiMai with MIT License | 6 votes |
/** * 根据获取到的位置在地图上移动"我"的位置 * * @param location */ private void navigateTo(BDLocation location) { double longitude = location.getLongitude(); double latitude = location.getLatitude(); String address = location.getAddrStr(); if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng) .radius(radius)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(location.getLatitude()); locationBuilder.longitude(location.getLongitude()); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example 4
Source File: AddressEditDelegate.java From FastWaiMai with MIT License | 6 votes |
/** * 根据收货地址的位置在地图上移动"我"的位置 */ private void navigateTo(double longitude, double latitude) { if (isFirstLocation) { currentLatLng = new LatLng(latitude, longitude); MapStatus.Builder builder = new MapStatus.Builder(); MapStatus mapStatus = builder.target(currentLatLng).zoom(17.0f).build(); mBaiduMap.animateMapStatus(MapStatusUpdateFactory .newMapStatus(mapStatus)); isFirstLocation = false; //反向地理解析(含有poi列表) mGeoCoder.reverseGeoCode(new ReverseGeoCodeOption() .location(currentLatLng)); } MyLocationData.Builder locationBuilder = new MyLocationData.Builder(); locationBuilder.latitude(latitude); locationBuilder.longitude(longitude); MyLocationData locationData = locationBuilder.build(); mBaiduMap.setMyLocationData(locationData); }
Example 5
Source File: BaiduMapRouteFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(getActivity()); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 6
Source File: RouteBaiduBusActivity.java From BmapLite with Apache License 2.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(this); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 7
Source File: NaviConfirmPointActivity.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 设置检索结果显示索引(若有多个结果则地图缩放到保证所有结果可见) **/ private void setPoiPosition() { if (aList.size() == 0 || poiOverlay == null) return; if (aList.size() == 1) { MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(aList.get(0).getLatitude(), aList.get(0).getLongitude())) .targetScreen(new Point(baiduMap.getMapStatus().targetScreen.x, baiduMap.getMapStatus().targetScreen.y / 4)) .zoom(17F); baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); } else poiOverlay.zoomToSpan(); }
Example 8
Source File: BaiduMapSelectPoiFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(getActivity()); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 9
Source File: RouteBaiduBusActivity.java From BmapLite with GNU General Public License v3.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(this); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 10
Source File: BaiduMapFragment.java From BmapLite with Apache License 2.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(getActivity()); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 11
Source File: MainActivity.java From Mobike with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { if (bdLocation == null || baiduMap == null) { return; } mBDLocation = bdLocation; MyLocationData locData = new MyLocationData.Builder() .accuracy(bdLocation.getRadius()) .direction(mCurrentX)//设定图标方向 // 此处设置开发者获取到的方向信息,顺时针0-360 .latitude(bdLocation.getLatitude()) .longitude(bdLocation.getLongitude()).build(); if (isNeedCurrentlocation) baiduMap.setMyLocationData(locData); currentLatitude = bdLocation.getLatitude(); currentLongitude = bdLocation.getLongitude(); mTvLocationInfo.setText(bdLocation.getAddrStr()); currentLL = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); MyLocationManager.getInstance().setCurrentLL(currentLL); MyLocationManager.getInstance().setAddress(bdLocation.getAddrStr()); startNodeStr = PlanNode.withLocation(currentLL); //option.setScanSpan(5000),每隔5000ms这个方法就会调用一次,而有些我们只想调用一次,所以要判断一下isFirstLoc if (isFirstLocation) { isFirstLocation = false; LatLng ll = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); //地图缩放比设置为18 builder.target(ll).zoom(18.0f); baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); changeLatitude = bdLocation.getLatitude(); changeLongitude = bdLocation.getLongitude(); if (!isServiceLive) { addOverLayout(currentLatitude, currentLongitude); } } }
Example 12
Source File: BaiduMapRouteFragment.java From BmapLite with Apache License 2.0 | 5 votes |
private void setCacheMapStatus() { CacheInteracter cacheInteracter = new CacheInteracter(getActivity()); LatLng latLng = new LatLng(cacheInteracter.getLatitude(), cacheInteracter.getLongitude()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(latLng).zoom(14.5f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); }
Example 13
Source File: RouteDetailActivity.java From Mobike with Apache License 2.0 | 4 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_route_detail); route_detail_mapview = (MapView) findViewById(R.id.route_detail_mapview); total_time = (TextView) findViewById(R.id.total_time); total_distance = (TextView) findViewById(R.id.total_distance); total_price = (TextView) findViewById(R.id.total_pricce); routeBaiduMap = route_detail_mapview.getMap(); route_detail_mapview.showZoomControls(false); startBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_start); endBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_end); initMap(); Intent intent = getIntent(); String time = intent.getStringExtra("totalTime"); String distance = intent.getStringExtra("totalDistance"); String price = intent.getStringExtra("totalPrice"); routePointsStr = intent.getStringExtra("routePoints"); routePoints = new Gson().fromJson(routePointsStr, new TypeToken<List<RoutePoint>>() { }.getType()); savaDatas(time,distance,price);//yiwen add List<LatLng> points = new ArrayList<LatLng>(); for (int i = 0; i < routePoints.size(); i++) { RoutePoint point = routePoints.get(i); LatLng latLng = new LatLng(point.getRouteLat(), point.getRouteLng()); Log.d("gaolei", "point.getRouteLat()----show-----" + point.getRouteLat()); Log.d("gaolei", "point.getRouteLng()----show-----" + point.getRouteLng()); points.add(latLng); } if (points.size() > 2) { OverlayOptions ooPolyline = new PolylineOptions().width(10) .color(0xFF36D19D).points(points); routeBaiduMap.addOverlay(ooPolyline); RoutePoint startPoint = routePoints.get(0); LatLng startPosition = new LatLng(startPoint.getRouteLat(), startPoint.getRouteLng()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(startPosition).zoom(18.0f); routeBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); RoutePoint endPoint = routePoints.get(routePoints.size() - 1); LatLng endPosition = new LatLng(endPoint.getRouteLat(), endPoint.getRouteLng()); addOverLayout(startPosition, endPosition); } total_time.setText("骑行时长:" + time + "分钟"); total_distance.setText("骑行距离:" + distance + "米"); total_price.setText("余额支付:" + price + "元"); }
Example 14
Source File: BaiduMapFragment.java From BmapLite with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 || BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324) { BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); if (isFirstLoc) { ((MainActivity) getActivity()).firstLocationComplete(); isFirstLoc = false; } isRequest = false; } }
Example 15
Source File: RouteBaiduBusActivity.java From BmapLite with Apache License 2.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(this); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 || BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324) { BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 16
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void initMap() { // Set the enlargement and reduction button mMapView.setMapCustomEnable(true); View child = mMapView.getChildAt(1); // delete logo if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app)); } mMapView.showZoomControls(false); mMapView.showScaleControl(false); mBaiduMap = mMapView.getMap(); // Open the location layer mBaiduMap.setMyLocationEnabled(true); // Close the traffic map mBaiduMap.setTrafficEnabled(false); mBaiduMap.setBaiduHeatMapEnabled(false); mBaiduMap.setIndoorEnable(false); mBaiduMap.setBuildingsEnabled(false); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); // set custom logo // Modify it to custom marker mCurrentMarker = BitmapDescriptorFactory .fromResource(R.drawable.car_point); mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor)); mCurrentLat = MapSdkWrapper.getLatitudeBd09ll(); mCurrentLon = MapSdkWrapper.getLongitudeBd09ll(); // set the direction information that developers get,clockwise:0-360 locData = new MyLocationData.Builder().accuracy(mCurrentAccracy) .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(mCurrentLat, mCurrentLon); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(ll); MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback); LogUtil.i(TAG, "Map is init"); }
Example 17
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void initMap() { // set button which can change large or small mMapView.setMapCustomEnable(true); View child = mMapView.getChildAt(1); // remove logo if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app)); } mMapView.showZoomControls(false); mMapView.showScaleControl(false); mBaiduMap = mMapView.getMap(); // enable location layer mBaiduMap.setMyLocationEnabled(true); // unable traffic picture mBaiduMap.setTrafficEnabled(false); mBaiduMap.setBaiduHeatMapEnabled(false); mBaiduMap.setIndoorEnable(false); mBaiduMap.setBuildingsEnabled(false); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); // set custom icon、marker mCurrentMarker = BitmapDescriptorFactory .fromResource(R.drawable.car_point); mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor)); mCurrentLat = MapSdkWrapper.getLatitudeBd09ll(); mCurrentLon = MapSdkWrapper.getLongitudeBd09ll(); // get direction info,clockwise 0-360 locData = new MyLocationData.Builder().accuracy((float) mCurrentAccracy) .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(mCurrentLat, mCurrentLon); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(ll); // you can customize the size. level=19,the default scale is 14--100 meter MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback); LogUtil.i(TAG, "Map is init"); }
Example 18
Source File: BaiduMapSelectPoiFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 ||BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324){ BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }
Example 19
Source File: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 || BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324) { BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324) { onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); if (isFirstLoc) { ((MainActivity) getActivity()).firstLocationComplete(); isFirstLoc = false; } isRequest = false; } }
Example 20
Source File: BaiduMapRouteFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) { return; } if (null == BApp.MY_LOCATION) { BApp.MY_LOCATION = new MyPoiModel(TypeMap.TYPE_BAIDU); } BApp.MY_LOCATION.setName("我的位置"); BApp.MY_LOCATION.setLatitude(location.getLatitude()); BApp.MY_LOCATION.setLongitude(location.getLongitude()); BApp.MY_LOCATION.setAltitude(location.getAltitude()); BApp.MY_LOCATION.setAccuracy(location.getRadius()); CacheInteracter interacter = new CacheInteracter(getActivity()); if (BApp.MY_LOCATION.getLongitude() == 0 || BApp.MY_LOCATION.getLatitude() == 0 ||BApp.MY_LOCATION.getLongitude() == 4.9E-324 || BApp.MY_LOCATION.getLatitude() == 4.9E-324){ BApp.MY_LOCATION.setLatitude(interacter.getLatitude()); BApp.MY_LOCATION.setLongitude(interacter.getLongitude()); } MyLocationData locData = new MyLocationData.Builder() .direction(mXDirection) .latitude(BApp.MY_LOCATION.getLatitude()) .longitude(BApp.MY_LOCATION.getLongitude()) .accuracy((float) BApp.MY_LOCATION.getAccuracy()) .build(); mBaiduMap.setMyLocationData(locData); if (isFirstLoc || isRequest) { if (location.getLatitude() == 0 || location.getLongitude() == 0 || location.getLatitude() == 4.9E-324 || location.getLongitude() == 4.9E-324){ onMessage("无法获取到位置信息,请连接网络后再试"); } MapStatus.Builder builder = new MapStatus.Builder(); builder.target(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude())).zoom(18f); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mSearchInteracter.searchLatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude(), 1, this); interacter.setLatitude(BApp.MY_LOCATION.getLatitude()); interacter.setLongitude(BApp.MY_LOCATION.getLongitude()); isRequest = false; isFirstLoc = false; } }