本文整理匯總了Java中com.baidu.mapapi.map.MapStatusUpdateFactory.newLatLngBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java MapStatusUpdateFactory.newLatLngBounds方法的具體用法?Java MapStatusUpdateFactory.newLatLngBounds怎麽用?Java MapStatusUpdateFactory.newLatLngBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.baidu.mapapi.map.MapStatusUpdateFactory
的用法示例。
在下文中一共展示了MapStatusUpdateFactory.newLatLngBounds方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: zoomByLatLngBounds
import com.baidu.mapapi.map.MapStatusUpdateFactory; //導入方法依賴的package包/類
public static void zoomByLatLngBounds(MapView mapView, LatLngBounds bounds, boolean animated) {
MapStatusUpdate update = MapStatusUpdateFactory.newLatLngBounds(bounds);
if (animated)
mapView.getMap().animateMapStatus(update);
else
mapView.getMap().setMapStatus(update);
}
示例2: zoomToFit
import com.baidu.mapapi.map.MapStatusUpdateFactory; //導入方法依賴的package包/類
@Override
public void zoomToFit(List<LatLong> coords) {
final BaiduMap map = getBaiduMap();
if (map == null) return;
if (!coords.isEmpty()) {
final List<LatLng> points = new ArrayList<LatLng>();
for (LatLong coord : coords)
points.add(MapUtils.coordToBaiduLatLng(coord));
final LatLngBounds bounds = getBounds(points);
final Activity activity = getActivity();
if (activity == null)
return;
final View rootView = ((ViewGroup)activity.findViewById(android.R.id.content)).getChildAt(0);
if (rootView == null)
return;
final int height = rootView.getHeight();
final int width = rootView.getWidth();
Log.d(TAG, String.format(Locale.US, "Screen W %d, H %d", width, height));
if (height > 0 && width > 0) {
MapStatusUpdate animation = MapStatusUpdateFactory.newLatLngBounds(bounds, width, height);
map.animateMapStatus(animation);
}
}
}
示例3: zoomToFit
import com.baidu.mapapi.map.MapStatusUpdateFactory; //導入方法依賴的package包/類
@Override
public void zoomToFit(List<LatLong> coords) {
if (!coords.isEmpty()) {
final List<LatLng> points = new ArrayList<LatLng>();
for (LatLong coord : coords)
points.add(DroneHelper.CoordToBaiduLatLang(coord));
final LatLngBounds bounds = getBounds(points);
MapStatusUpdate update = MapStatusUpdateFactory.newLatLngBounds(bounds);
getBaiduMap().animateMapStatus(update);
}
}
示例4: onGetSearchResult
import com.baidu.mapapi.map.MapStatusUpdateFactory; //導入方法依賴的package包/類
@Override
public void onGetSearchResult(CloudSearchResult result, int error) {
if (progress.isShowing()) {
progress.dismiss();
}
if (result != null && result.poiList != null && result.poiList.size() > 0) {
Log.d(TAG, "onGetSearchResult, result length: " + result.poiList.size());
mPoiInfos = new ArrayList<CloudPoiInfo>();
mPoiInfos.addAll(result.poiList);
// if (mIsUpdatePoi) {
// String latitude = lastLocation.getLatitude() + "";
// String longitude = lastLocation.getLongitude() + "";
// String addrStr = lastLocation.getAddrStr();
// for (CloudPoiInfo info : mPoiInfos) {
// Map<String, Object> extras = info.extras;
//
// if (info.tags.equals(mUser.getObjectId())) {
// updatePoi(String.valueOf(info.uid), mUser.getUsername(), addrStr, latitude, longitude, "1", "98950");
// }
// }
// mIsUpdatePoi = false;
// }
mBaiduMap.clear();
BitmapDescriptor bd = BitmapDescriptorFactory.fromResource(R.drawable.icon_geo);
LatLng ll;
LatLngBounds.Builder builder = new Builder();
for (CloudPoiInfo info : mPoiInfos) {
if (info.title.equals(mUser.getUsername())) {
continue;
}
ll = new LatLng(info.latitude, info.longitude);
OverlayOptions oo = new MarkerOptions().icon(bd).position(ll).title(info.title);
mBaiduMap.addOverlay(oo);
builder.include(ll);
LatLngBounds bounds = builder.build();
MapStatusUpdate u = MapStatusUpdateFactory.newLatLngBounds(bounds);
mBaiduMap.animateMapStatus(u);
}
}
}
示例5: drawHistoryTrack
import com.baidu.mapapi.map.MapStatusUpdateFactory; //導入方法依賴的package包/類
/** 繪製曆史軌跡
*
* @param points
*/
private void drawHistoryTrack(final List<LatLng> points,final double distance) {
// 繪製新覆蓋物前,清空之前的覆蓋物
mBaiduMap.clear();
if(points.size() == 1){
points.add(points.get(0));
}
if(points == null || points.size() == 0){
TrackApplication.showMessage("當前查詢無軌跡點");
resetMarker();
}else if (points.size() > 1) {
LatLng llc = points.get(0);
LatLng llD = points.get(points.size() - 1);
LatLngBounds bounds = new LatLngBounds.Builder()
.include(llc).include(llD).build();
mapStatusUpdate = MapStatusUpdateFactory.newLatLngBounds(bounds);
//起點圖標
bmStart = BitmapDescriptorFactory.fromResource(R.drawable.icon_start);
bmEnd = BitmapDescriptorFactory.fromResource(R.drawable.icon_end);
//添加起點圖標
startMarker = new MarkerOptions()
.position(points.get(points.size() - 1)).icon(bmStart)
.zIndex(9).draggable(true);
//添加終點圖標
endMarker = new MarkerOptions().position(points.get(0))
.icon(bmEnd).zIndex(9).draggable(true);
//添加路線
polylineOptions = new PolylineOptions().width(10)
.color(Color.RED).points(points);
markerOptions = new MarkerOptions();
markerOptions.flat(true);
markerOptions.anchor(0.5f, 0.5f);
markerOptions.icon(BitmapDescriptorFactory
.fromResource(R.drawable.icon_gcoding));
markerOptions.position(points.get(points.size() - 1));
addMarker();
}
}