googleMap----放大,缩小,东南西北,四种视图切换代码
16lz
2021-12-04
mapView的xml
<view android:id="@+id/mv"
class="com.google.android.maps.MapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="0yxPVuoWg4JGeXCpA3WaJCnbiR2lLfCC_yCTqfA"
/>
mapController = mapView.getController();
map控制器似乎是控制地图移动的,缩放和中心位置都通过他设定
放大: mapController.zoomIn();
缩小: mapController.zoomOut();
向北: GeoPoint point = new GeoPoint(mapView.getMapCenter()
.getLatitudeE6()
+ mapView.getLatitudeSpan() / 4, mapView.getMapCenter()
.getLongitudeE6());
mapController.setCenter(point);
=================小贴士===================================
如果只是想把点放到地图上,而不是让map以点为中心显示,做法是
mapController.animateTo(point);//激活就可以了
mapController.setCenter(point);//激活并放到视图中间
东南西北都是在经度和纬度上改变下
设置街景视图: mapView.setSatellite(false);
mapView.setStreetView(true);
mapView.setTraffic(false);
街景,交通,卫星三个视图类似
<view android:id="@+id/mv"
class="com.google.android.maps.MapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="0yxPVuoWg4JGeXCpA3WaJCnbiR2lLfCC_yCTqfA"
/>
mapController = mapView.getController();
map控制器似乎是控制地图移动的,缩放和中心位置都通过他设定
放大: mapController.zoomIn();
缩小: mapController.zoomOut();
向北: GeoPoint point = new GeoPoint(mapView.getMapCenter()
.getLatitudeE6()
+ mapView.getLatitudeSpan() / 4, mapView.getMapCenter()
.getLongitudeE6());
mapController.setCenter(point);
=================小贴士===================================
如果只是想把点放到地图上,而不是让map以点为中心显示,做法是
mapController.animateTo(point);//激活就可以了
mapController.setCenter(point);//激活并放到视图中间
东南西北都是在经度和纬度上改变下
设置街景视图: mapView.setSatellite(false);
mapView.setStreetView(true);
mapView.setTraffic(false);
街景,交通,卫星三个视图类似
更多相关文章
- 【Android(安卓)UI】Android开发之View的几种布局方式及实践
- Android自定义视图四:定制onMeasure强制显示为方形
- android. MVC三层分层
- [Android]LayoutInflater的inflate方法半详解
- Android(安卓)自定义控件
- android之高德地图学习
- Google:五亿Android设备激活
- Unity3D游戏开发之在Android视图中嵌入Unity视图
- Android游戏框架与常识