本文整理汇总了Java中com.amap.api.maps.CameraUpdateFactory.newCameraPosition方法的典型用法代码示例。如果您正苦于以下问题:Java CameraUpdateFactory.newCameraPosition方法的具体用法?Java CameraUpdateFactory.newCameraPosition怎么用?Java CameraUpdateFactory.newCameraPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.maps.CameraUpdateFactory
的用法示例。
在下文中一共展示了CameraUpdateFactory.newCameraPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.amap.api.maps.CameraUpdateFactory; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View sView = inflater.inflate(R.layout.fragment_map_simple, container, false);
mMapView = (MapView) sView.findViewById(R.id.map_simple);
mMapView.onCreate(savedInstanceState);
AMap map = mMapView.getMap();
map.setMapType(AMap.MAP_TYPE_NIGHT);
map.getUiSettings().setZoomControlsEnabled(false);
map.getUiSettings().setAllGesturesEnabled(false);
LatLng loc = new LatLng(39.9793157, 116.3107618);
CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(loc,14 ,0,0));
map.animateCamera(mCameraUpdate, 1000, null);
if(mCircleTask == null) {
mCircleTask = new CircleTask(map, loc, 15, 20, 40);
}
return sView;
}
示例2: centerMap
import com.amap.api.maps.CameraUpdateFactory; //导入方法依赖的package包/类
/**
* Map居中到指定点,动画移动Map相机 并且开始加载周边photo
*/
private void centerMap(LatLng loc) {
if (loc != null) {
mCurrentLocation = loc;
AMap aMap = mMapView.getMap();
CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(loc,14,0,0));
aMap.animateCamera(mCameraUpdate, 1000, null);
// 更新闪烁点
if (mCircle == null) {
mCircle = new CircleTask(aMap, loc);
} else {
mCircle.updateLocation(loc);
}
// 开始加载周边photo
//添加测试数据
new Thread() {
public void run() {
int[] avatars = new int[] {R.drawable.avatar1, R.drawable.avatar2, R.drawable.avatar3, R.drawable.avatar4, R.drawable.avatar5, R.drawable.avatar6};
Random r = new Random(1);
//随机10000个点
for (int i = 0; i < 500; i++) {
double lat = Math.random() / 100 * (r.nextBoolean() ? (1) : (-1)) + mCurrentLocation.latitude;
double lon = Math.random() / 100 * (r.nextBoolean() ? (1) : (-1)) + mCurrentLocation.longitude;
LatLng latLng = new LatLng(lat, lon, false);
RegionItem regionItem = new RegionItem(latLng,
"test" + i, avatars[r.nextInt(6)], i);
mClusterOverlay.addClusterItem(regionItem);
}
}
}.start();
}
}
示例3: updateLoc
import com.amap.api.maps.CameraUpdateFactory; //导入方法依赖的package包/类
public void updateLoc(LatLng loc) {
AMap aMap = mMapView.getMap();
CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(loc,14 ,0,0));
aMap.animateCamera(mCameraUpdate, 300, null);
mCircleTask.updateLocation(loc);
}
示例4: onAmapLocationSucces
import com.amap.api.maps.CameraUpdateFactory; //导入方法依赖的package包/类
/**
* 在mapservice成功定位后回调的业务逻辑
*/
public void onAmapLocationSucces(Location location) {
//真实路径点
LatLng mTemplatLng = new LatLng(location.lat, location.lng);
//测试
// dbManager.add(location);
//模拟路径点
// LatLng mTemplatLng = new LatLng(31.972 + i, 118.755 + i);
//i = i + 0.01;
// latLngs.add(mTemplatLng);
//如果第一个点是起点,先画个起点
if (isFirstPoint) {
// markerOptions.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.start2_32)));
markerOptions.anchor(0.5f, 1.0f).icon(BitmapDescriptorFactory.fromResource(R.drawable.start2_80));
//添加锚点
markerOptions.position(mTemplatLng).title("位置:" + location.address).snippet("时间" + location.time);
//画锚点
aMap.addMarker(markerOptions);
isFirstPoint = false;
}
//画完第一个起始点后,将marker点改为小圆点
markerOptions.anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromResource(R.drawable.point_32));
//添加锚点
markerOptions.position(mTemplatLng).title("位置:" + location.address).snippet("时间" + location.time);
//画锚点
aMap.addMarker(markerOptions);
//添加坐标
polylineOptions.add(mTemplatLng);
//链接坐标
aMap.addPolyline(polylineOptions);
//第一个参数是缩放比例,0是倾斜度,30显示比例
mUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(mTemplatLng, 17, 0, 0));
aMap.moveCamera(mUpdate);//移动摄像头
//解决持续绘制时越来越卡顿的算法
count++;
if (count==2){
mlastlatLng=mTemplatLng;
polylineOptions = new PolylineOptions().width(10).color(lineColor);
polylineOptions.add(mlastlatLng);
count=0;
}
}