com.amap.api.maps.CameraUpdateFactory Java Examples

The following examples show how to use com.amap.api.maps.CameraUpdateFactory. 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: AmapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void setModeEDog(boolean isChecked) {
    if (isChecked) {
        btnLocation.setImageResource(R.drawable.ic_explore_24dp);
        mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE);
        mAmap.setMyLocationStyle(mLocClient);
        mIsModeEDog = true;
    } else {
        btnLocation.setImageResource(R.drawable.ic_my_location_24dp);
        mLocClient.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
        mAmap.setMyLocationStyle(mLocClient);

        mAmap.moveCamera(CameraUpdateFactory.changeBearing(0));
        mAmap.moveCamera(CameraUpdateFactory.changeTilt(0));
        mIsModeEDog = false;
    }

}
 
Example #2
Source File: GeoFence_District_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawFence(GeoFence fence) {
	switch (fence.getType()) {
		case GeoFence.TYPE_ROUND :
		case GeoFence.TYPE_AMAPPOI :
			drawCircle(fence);
			break;
		case GeoFence.TYPE_POLYGON :
		case GeoFence.TYPE_DISTRICT :
			drawPolygon(fence);
			break;
		default :
			break;
	}

	// 设置所有maker显示在当前可视区域地图中
	LatLngBounds bounds = boundsBuilder.build();
	mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
}
 
Example #3
Source File: AmapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btn_location:
            requestLoc();
            break;
        case R.id.btn_zoom_in:
            if (mAmap.getMaxZoomLevel() > mAmap.getCameraPosition().zoom) {
                mAmap.animateCamera(CameraUpdateFactory.zoomIn());
            }
            break;
        case R.id.btn_zoom_out:
            if (mAmap.getMinZoomLevel() < mAmap.getCameraPosition().zoom) {
                mAmap.animateCamera(CameraUpdateFactory.zoomOut());
            }
            break;
        case R.id.image_compass:
            if (mAmap.getCameraPosition().bearing != 0){
                mAmap.animateCamera(CameraUpdateFactory.changeBearing(0));
            }
            break;
    }
}
 
Example #4
Source File: AMapViewManager.java    From react-native-amap with MIT License 6 votes vote down vote up
@Override
public void updateExtraData(MapView view, Object extraData) {
    // if boundsToMove is not null, we now have the MapView's width/height, so we can apply
    // a proper camera move
    if (boundsToMove != null) {
      HashMap<String, Float> data = (HashMap<String, Float>) extraData;
      float width = data.get("width");
      float height = data.get("height");
      view.getMap().moveCamera(
          CameraUpdateFactory.newLatLngBounds(
              boundsToMove,
              (int) width,
              (int) height,
              0
          )
      );
      boundsToMove = null;
    }
}
 
Example #5
Source File: ReviewPresenterImpl.java    From RunMap with Apache License 2.0 6 votes vote down vote up
private void prepareAnimation(final List<List<LatLng>> drawSource){
    mapInstance.clear();
    this.mDrawSource = drawSource;
    mSegmentIndex = 0;
    if(isFirstAnimation) {
        isFirstAnimation = false;
        TaskHanler.getInstance().sendTaskDelayed(new Runnable() {
            @Override
            public void run() {
                mapInstance.moveToSpecficCamera(CameraUpdateFactory.newCameraPosition(
                        new CameraPosition(drawSource.get(mSegmentIndex).get(0), 16, 0, 0)));
            }
        }, 1000);
    }
    else {
        mapInstance.moveToSpecficCamera(CameraUpdateFactory.newCameraPosition(
                new CameraPosition(drawSource.get(mSegmentIndex).get(0), 16, 0, 0)));
    }

    mapInstance.drawTrackAnimation(drawSource.get(mSegmentIndex), mSegmentIndex, new TrackLineMoveListener());
}
 
Example #6
Source File: AMapViewManager.java    From react-native-amap with MIT License 6 votes vote down vote up
@ReactProp(name = "region")
public void setRegion(MapView mapView, @Nullable ReadableMap region) {
    if (region == null) return;
    AMap map = mapView.getMap();
    Double lat = region.getDouble("latitude");
    Double lng = region.getDouble("longitude");
    Double lngDelta = region.getDouble("longitudeDelta");
    Double latDelta = region.getDouble("latitudeDelta");
    LatLngBounds bounds = new LatLngBounds(
        new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
        new LatLng(lat + latDelta / 2, lng + lngDelta / 2)  // northeast
    );
    if (mapView.getHeight() <= 0 || mapView.getWidth() <= 0) {
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 10));
        boundsToMove = bounds;
    } else {
        map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
    }
}
 
Example #7
Source File: GeoFence_Keyword_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawFence(GeoFence fence) {
	switch (fence.getType()) {
		case GeoFence.TYPE_ROUND :
		case GeoFence.TYPE_AMAPPOI :
			drawCircle(fence);
			break;
		case GeoFence.TYPE_POLYGON :
		case GeoFence.TYPE_DISTRICT :
			drawPolygon(fence);
			break;
		default :
			break;
	}

	// 设置所有maker显示在当前可视区域地图中
	LatLngBounds bounds = boundsBuilder.build();
	mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
}
 
Example #8
Source File: AmapWrapper.java    From RunMap with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化地图显示样式
 * @param map
 */
private void initAmap(AMap map){
    this.mAmap = map;
    //照传入的CameraUpdate参数移动可视区域。
    map.animateCamera(CameraUpdateFactory.zoomTo(19));
    //设置定位源
    map.setLocationSource(mAmapStateListener);
    //显示室内地图
    map.showIndoorMap(true);
    //设置是否打开定位图层
    map.setMyLocationEnabled(true);
    MyLocationStyle style = new MyLocationStyle();
    //去除定位中心圆圈
    style.strokeWidth(0);
    style.radiusFillColor(Color.TRANSPARENT);
    //定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动
    style.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
    map.setMyLocationStyle(style);
    //去除缩放按钮
    UiSettings settings = map.getUiSettings();
    settings.setZoomControlsEnabled(false);
}
 
Example #9
Source File: GeoFence_Nearby_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawFence(GeoFence fence) {
	switch (fence.getType()) {
		case GeoFence.TYPE_ROUND :
		case GeoFence.TYPE_AMAPPOI :
			drawCircle(fence);
			break;
		case GeoFence.TYPE_POLYGON :
		case GeoFence.TYPE_DISTRICT :
			drawPolygon(fence);
			break;
		default :
			break;
	}

	// 设置所有maker显示在当前可视区域地图中
	LatLngBounds bounds = boundsBuilder.build();
	mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

	removeMarkers();
}
 
Example #10
Source File: HoleActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 为多边形添加空心洞
 * @param view
 */
public void clickPolygonAddHole(View view) {

    aMap.moveCamera(CameraUpdateFactory.changeLatLng(Constants.SHANGHAI));

    // 清除多边形的空心洞
    polygon.setHoleOptions(null);

    // 构建多边形空心配置项
    PolygonHoleOptions polygonOptions = new PolygonHoleOptions();
    polygonOptions.addAll(createRectangle(new LatLng(31.238068, 121.501654), 0.25, 0.25));

    // 构建圆形空心配置项
    LatLng latLng = new LatLng(30.746626, 120.756966);
    CircleHoleOptions circleOptions = new CircleHoleOptions();
    circleOptions.center(latLng).radius(15000f);

    List<BaseHoleOptions> list = new ArrayList<>();

    list.add(polygonOptions);
    list.add(circleOptions);

    // 添加空心洞
    polygon.setHoleOptions(list);
}
 
Example #11
Source File: TileOverlayActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
private void setUpMap() {

		aMap.moveCamera(CameraUpdateFactory.zoomTo(4));
		aMap.setMapTextZIndex(2);

		aMap.addTileOverlay(new TileOverlayOptions().tileProvider(new UrlTileProvider(256, 256) {
			
			@Override
			public URL getTileUrl(int x, int y, int zoom) {
				try {
					return new URL(String.format(url, x, y, zoom));
				} catch (Exception  e) {
					e.printStackTrace();
				}
				return null;
			}
		})
		.diskCacheEnabled(true)  
        .diskCacheDir("/storage/emulated/0/amap/cache")
        .diskCacheSize(100000)  
        .memoryCacheEnabled(true)  
        .memCacheSize(100000));
	}
 
Example #12
Source File: MapsModule.java    From Maps with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onGaodeLocationChanged(AMapLocation aMapLocation) {

    if ((mLocation == null || (mLocation.getLatitude() != aMapLocation.getLatitude() || mLocation.getLongitude() != aMapLocation.getLongitude()))) {
        Log.d("MapsAction", "onLocationChanged");

        if (mIsEnableMyLocation) {

            LatLng latLng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
            mGaodeMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));

            if (marker == null) {
                MarkerOptions mMyLocationMarker = new MarkerOptions().anchor(0.5f, 0.5f).position(latLng).icon(mMyLocationIcon);
                marker = mGaodeMap.addMarker(mMyLocationMarker);
            } else {
                marker.setPosition(latLng);
            }

        }
        mLocation = aMapLocation;
    }

}
 
Example #13
Source File: MainActivity.java    From RecordPath3D with Apache License 2.0 6 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation amapLocation) {
	if (mListener != null && amapLocation != null) {
		if (amapLocation != null && amapLocation.getErrorCode() == 0) {
			mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
			LatLng mylocation = new LatLng(amapLocation.getLatitude(),
					amapLocation.getLongitude());
			mAMap.moveCamera(CameraUpdateFactory.changeLatLng(mylocation));
			if (btn.isChecked()) {
				record.addpoint(amapLocation);
				mPolyoptions.add(mylocation);
				redrawline();
			}
		} else {
			String errText = "定位失败," + amapLocation.getErrorCode() + ": "
					+ amapLocation.getErrorInfo();
			Log.e("AmapErr", errText);
		}
	}
}
 
Example #14
Source File: CustomLocationModeActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 同时修改自定义定位小蓝点和地图的位置
 * @param latLng
 */
private void startMoveLocationAndMap(LatLng latLng) {

	//将小蓝点提取到屏幕上
	if(projection == null) {
		projection = aMap.getProjection();
	}
	if(locationMarker != null && projection != null) {
		LatLng markerLocation = locationMarker.getPosition();
		Point screenPosition = aMap.getProjection().toScreenLocation(markerLocation);
		locationMarker.setPositionByPixels(screenPosition.x, screenPosition.y);

	}

	//移动地图,移动结束后,将小蓝点放到放到地图上
	myCancelCallback.setTargetLatlng(latLng);
	//动画移动的时间,最好不要比定位间隔长,如果定位间隔2000ms 动画移动时间最好小于2000ms,可以使用1000ms
	//如果超过了,需要在myCancelCallback中进行处理被打断的情况
	aMap.animateCamera(CameraUpdateFactory.changeLatLng(latLng),1000,myCancelCallback);

}
 
Example #15
Source File: RouteAmapBusActivity.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btn_location:
            requestLoc();
            break;
        case R.id.btn_zoom_in:
            if (mAmap.getMaxZoomLevel() > mAmap.getCameraPosition().zoom) {
                mAmap.animateCamera(CameraUpdateFactory.zoomIn());
            }
            break;
        case R.id.btn_zoom_out:
            if (mAmap.getMinZoomLevel() < mAmap.getCameraPosition().zoom) {
                mAmap.animateCamera(CameraUpdateFactory.zoomOut());
            }
            break;
        case R.id.image_compass:
            if (mAmap.getCameraPosition().bearing != 0) {
                mAmap.animateCamera(CameraUpdateFactory.changeBearing(0));
            }
            break;
    }
}
 
Example #16
Source File: GeoFence_District_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void drawFence(GeoFence fence) {
	switch (fence.getType()) {
		case GeoFence.TYPE_ROUND :
		case GeoFence.TYPE_AMAPPOI :
			drawCircle(fence);
			break;
		case GeoFence.TYPE_POLYGON :
		case GeoFence.TYPE_DISTRICT :
			drawPolygon(fence);
			break;
		default :
			break;
	}

	// 设置所有maker显示在当前可视区域地图中
	LatLngBounds bounds = boundsBuilder.build();
	mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
}
 
Example #17
Source File: PoiOverlay.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 移动镜头到当前的视角。
 * @since V2.1.0
 */
public void zoomToSpan() {
	try{
		if (mPois != null && mPois.size() > 0) {
			if (mAMap == null)
				return;
			if(mPois.size()==1){
				mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mPois.get(0).getLatLonPoint().getLatitude(),
						mPois.get(0).getLatLonPoint().getLongitude()), 18f));
			}else{
				LatLngBounds bounds = getLatLngBounds();
				mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 5));
			}
		}
	}catch(Throwable e){
		e.printStackTrace();
	}
}
 
Example #18
Source File: PoiOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 移动镜头到当前的视角。
 * @since V2.1.0
 */
public void zoomToSpan() {
	try{
		if (mPois != null && mPois.size() > 0) {
			if (mAMap == null)
				return;
			if(mPois.size()==1){
				mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mPois.get(0).getLatLonPoint().getLatitude(),
						mPois.get(0).getLatLonPoint().getLongitude()), 18f));
			}else{
				LatLngBounds bounds = getLatLngBounds();
				mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 5));
			}
		}
	}catch(Throwable e){
		e.printStackTrace();
	}
}
 
Example #19
Source File: RouteDistanceActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
public void onMapLoaded() {

	//展示出所有点
	LatLngBounds.Builder builder = new LatLngBounds.Builder();
	builder.include(AMapUtil.convertToLatLng(start0));
	builder.include(AMapUtil.convertToLatLng(start1));
	builder.include(AMapUtil.convertToLatLng(start2));
	builder.include(AMapUtil.convertToLatLng(start3));
	builder.include(AMapUtil.convertToLatLng(dest));
	aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100));

	distanceSearch = new DistanceSearch(this);
	distanceSearch.setDistanceSearchListener(this);

	searchDistanceResult(DistanceSearch.TYPE_DRIVING_DISTANCE);
}
 
Example #20
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 逆地理编码回调
 */
@Override
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
	dismissDialog();
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getRegeocodeAddress() != null
				&& result.getRegeocodeAddress().getFormatAddress() != null) {
			addressName = result.getRegeocodeAddress().getFormatAddress()
					+ "附近";
			aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
					AMapUtil.convertToLatLng(latLonPoint), 15));
			regeoMarker.setPosition(AMapUtil.convertToLatLng(latLonPoint));
			ToastUtil.show(ReGeocoderActivity.this, addressName);
		} else {
			ToastUtil.show(ReGeocoderActivity.this, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this, rCode);
	}
}
 
Example #21
Source File: GeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 地理编码查询回调
 */
@Override
public void onGeocodeSearched(GeocodeResult result, int rCode) {
	dismissDialog();
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getGeocodeAddressList() != null
				&& result.getGeocodeAddressList().size() > 0) {
			GeocodeAddress address = result.getGeocodeAddressList().get(0);

			if(address != null) {
				aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
						AMapUtil.convertToLatLng(address.getLatLonPoint()), 15));
				geoMarker.setPosition(AMapUtil.convertToLatLng(address
						.getLatLonPoint()));
				addressName = "经纬度值:" + address.getLatLonPoint() + "\n位置描述:"
						+ address.getFormatAddress();
				ToastUtil.show(GeocoderActivity.this, addressName);
			}
		} else {
			ToastUtil.show(GeocoderActivity.this, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this, rCode);
	}
}
 
Example #22
Source File: ZoomActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
	switch (v.getId()) {
	/**
	 * 点击地图放大按钮响应事件
	 */
	case R.id.zoom_in:
		changeCamera(CameraUpdateFactory.zoomIn(), null);
		break;
	/**
	 * 点击地图缩小按钮响应事件
	 */
	case R.id.zoom_out:
		changeCamera(CameraUpdateFactory.zoomOut(), null);
		break;
	default:
		break;
	}
}
 
Example #23
Source File: ContainsActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
private void setUpMap() {
		aMap.setOnMapClickListener(this);
		// 绘制一个长方形
		PolygonOptions pOption = new PolygonOptions();
		pOption.add(new LatLng(39.926516, 116.389366));
		pOption.add(new LatLng(39.924870, 116.403270));
		pOption.add(new LatLng(39.918090, 116.406274));
		pOption.add(new LatLng(39.909466, 116.397863));
		pOption.add(new LatLng(39.913021, 116.387134));
		polygon = aMap.addPolygon(pOption.strokeWidth(4)
				.strokeColor(Color.argb(50, 1, 1, 1))
				.fillColor(Color.argb(50, 1, 1, 1)));
		aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.926516,
				116.389366), 16));
//		
	}
 
Example #24
Source File: GeoFence_District_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
void init() {
	if (mAMap == null) {
		mAMap = mMapView.getMap();
		mAMap.getUiSettings().setRotateGesturesEnabled(false);
		mAMap.moveCamera(CameraUpdateFactory.zoomBy(6));
		setUpMap();
	}

	resetView();
	resetView_district();

	btAddFence.setOnClickListener(this);
	cbAlertIn.setOnCheckedChangeListener(this);
	cbAlertOut.setOnCheckedChangeListener(this);
	cbAldertStated.setOnCheckedChangeListener(this);

	IntentFilter fliter = new IntentFilter(
			ConnectivityManager.CONNECTIVITY_ACTION);
	fliter.addAction(GEOFENCE_BROADCAST_ACTION);
	registerReceiver(mGeoFenceReceiver, fliter);
	
	/**
	 * 创建pendingIntent
	 */
	fenceClient.createPendingIntent(GEOFENCE_BROADCAST_ACTION);
	fenceClient.setGeoFenceListener(this);
	/**
	 * 设置地理围栏的触发行为,默认为进入
	 */
	fenceClient.setActivateAction(GeoFenceClient.GEOFENCE_IN);
}
 
Example #25
Source File: ShareActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 添加模拟位置地图展示
 * 
 * @param snippet
 */
private void addTestLocationMarker(String snippet) {
	mAMap.clear();
	String title = "我的位置";
	addMarker(POI_POINT.getLatitude(), POI_POINT.getLongitude(), title,
			snippet,
			BitmapDescriptorFactory
					.fromResource(R.drawable.location_marker));
	LatLng latlng = new LatLng(POI_POINT.getLatitude(),
			POI_POINT.getLongitude());
	mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 18));
}
 
Example #26
Source File: RouteOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 移动镜头到当前的视角。
 * @since V2.1.0
 */
public void zoomToSpan() {
	if (startPoint != null) {
		if (mAMap == null)
			return;
		try {
			LatLngBounds bounds = getLatLngBounds();
			mAMap.animateCamera(CameraUpdateFactory
					.newLatLngBounds(bounds, 50));
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
 
Example #27
Source File: BusLineOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 移动镜头到当前的视角。
 *
 * @since V2.1.0
 */
public void zoomToSpan() {
    if (mAMap == null)
        return;
    try {
        List<LatLonPoint> coordin = mBusLineItem.getDirectionsCoordinates();
        if (coordin != null && coordin.size() > 0) {
            LatLngBounds bounds = getLatLngBounds(coordin);
            mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 5));
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
Example #28
Source File: CustomLocationActivity.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private void init() {
    if (this.aMap == null) {
        this.aMap = this.mapView.getMap();
        setUpMap();
        this.aMap.moveCamera(CameraUpdateFactory.zoomTo(15.5f));
    }
    this.mGPSModeGroup = (RadioGroup) findViewById(R.id.gps_radio_group);
    this.mGPSModeGroup.setVisibility(8);
    this.mLocationErrText = (TextView) findViewById(R.id.location_errInfo_text);
    this.mLocationErrText.setVisibility(8);
}
 
Example #29
Source File: RouteOverlay.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 移动镜头到当前的视角。
 * @since V2.1.0
 */
public void zoomToSpan() {
	if (startPoint != null) {
		if (mAMap == null) {
			return;
		}
		try {
			LatLngBounds bounds = getLatLngBounds();
			mAMap.animateCamera(CameraUpdateFactory
					.newLatLngBounds(bounds, 100));
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
 
Example #30
Source File: PlaceMapFragment.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
/**
 *  不用post会报“the map must have a size”错误,why
 *
 * @param place
 */
private void zoomMarker(ArrayList<PlaceBrief> place) {
    mMapView.post(() -> {
        LatLngBounds.Builder boundsBuild = new LatLngBounds.Builder();
        boundsBuild.include(mMyLocation.getPosition());
        for (PlaceBrief placeBrief : place) {
            boundsBuild.include(new LatLng(placeBrief.getLat(), placeBrief.getLng()));
        }
        aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(boundsBuild.build(), 10));
    });
}