?
keytool -list -alias androiddebugkey -keystore “ …..” -storepass android -keypass android??? 其中””中的是你自己刚得到的keystore的位置。若要求输密码则是“android” 得到认证指纹B9:BD:E8:7B:B2:21:B7:9E:15:12:70:44:12:30:62:B0
<com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey=" 0gn_orY7fE7XNXBtOjG7GSsNcPkhoszWbvVs2CQ " />
<uses-permission android:name="android.permission.access_COARSE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET" />
<uses-library android:name="com.google.android.maps" />
1)MapController
?????????? 控制地图移动,伸缩,以某个GPS坐标为中心,控制MapView中的view组件,管理Overlay,提供View的基本功能。
??????常用方法:animateTo(GeoPoint point)? setCenter(GeoPointpoint)? setZoom(int zoomLevel) 等。
?
2)MapView
Mapview是用来显示地图的view, 它派生自android.view.ViewGroup。当MapView获得焦点,可以控制地图的移动和缩放。
地图可以以不同的形式来显示出来,如街景模式,卫星模式等,通过setSatellite(boolean)? setTraffic(boolean), setStreetView(boolean) 方法。
3)MapActivity
??????管理Activity的生命周期,为mapview建立及取消对mapservice的连接。
??????MapActivity是一个抽象类,任何想要显示MapView的activity都需要派生自MapActivity。并且在其派生类的onCreate()中,都要创建一个MapView实例,可以通过layout XML来创建。
4)Overlay
?????Overlay是覆盖到MapView的最上层,可以扩展其ondraw接口,自定义在MapView中显示一些自己的东西。MapView通过MapView.getOverlays()对Overlay进行管理。
??????集成了Android.location中接收当前坐标的接口,集成SersorManager中CCompassSensor的接口,我们只需要enableMyLocation(),enableCompass就可以让我们的程序拥有实时的MyLocation以及Compass 功能。
6)ItemlizedOverlay
???它包含了一个OverlayItems列表。它为每个点绘制标记点,和维护一个焦点选中的item,同时也负责把一个屏幕点击匹配到item上去,分发焦点改变事件给备选的监听器。
7)Projection:MapView中GPS坐标与设备坐标的转换(GeoPoint和Point)。
五.移动和缩放的实现:
1)移动:
GeoPoint pt = new GeoPoint(mapView.getMapCenter().getLatitudeE6(), mapView.getMapCenter().getLongitudeE6()+ mapView.getLongitudeSpan() / 4); mc.setCenter(pt);
?
?
2)缩放:
mapView.setBuiltInZoomControls(true); public void zoomIn() { mc.zoomIn(); } public void zoomOut() { mc.zoomOut(); }?
?
? 地图模式主要有街景模式,交通模式,卫星模式。
?
????? 通过mapView.setTraffic()?? mapView.setSatellite()?? mapView.setStreetView()?来设置使用街景模式。
???例如:
public void setStreetView() { mapView.setTraffic(false); mapView.setSatellite(false); mapView.setStreetView(true); }
?
???? 调用方式:? mapView.setStreetView();
?
1)MyLocationOverlay:? (maps.jar) 在map上增加一个显示定位地址的overlay
? enableMyLocation()
? runOnFirstFix()
2)LocationManager:? (location.jar)?
? getBastProvider():得到最佳的位置提供者。
? getLastKnownLocation():得到当前的位置。
??
3)MyLocationOverlay:? (maps.jar) 在map上增加一个显示定位地址的overlay
? enableMyLocation():尝试开启MyLocation功能,
? runOnFirstFix():把一个runnable加入队列,一旦收到一个位置信息,这个runnable就被执行。
4)LocationManager:? (location.jar)?
? getBastProvider():得到最佳的位置提供者。
? getLastKnownLocation():得到当前的位置。
5)LocationListener接口(location) 我们可以实现onLocationChanged(Location loc)方法来动态的监听位置的变化。
?
private void initMyLocation() {loverlay = new MyLocationOverlay(this, mapView);loverlay.enableMyLocation();loverlay.runOnFirstFix(new Runnable() {public void run() {mc = mapView.getController();mc.animateTo(loverlay.getMyLocation());}});mapView.getOverlays().add(loverlay);}LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); String provider = locationManager.getBestProvider(criteria, true); Location location = locationManager.getLastKnownLocation(provider); Double latitude = location.getLatitude() * 1E6; Double longitude = location.getLongitude() * 1E6; geoPoint = new GeoPoint(latitude.intValue(), longitude.intValue());
?七.添加图钉
1)通过继承maps的overlay后重写draw()方法。适合添加某一个图钉。
2)通过继承maps的ItemizedOverlay后重写draw()方法,适合添加一批相同的图钉,并维护每个图钉的焦点。
List<OverlayItem> locations = new ArrayList<OverlayItem>(); populate();public void draw(Canvas canvas, MapView mapView, boolean shadow) {super.draw(canvas, mapView, shadow);boundCenterBottom(marker);}
?
?
?
1)Geocoder
? ?getFromLocation(double latitude, double longitude, int maxResults)
? ?getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude)
? ?getFromLocationName(String locationName, int maxResults)
?
?
?