本文整理汇总了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();
}
}