今天看了一些视频,学习的google map下面是一些总结
1生成密钥
步骤:首先获得密钥打开eclipse>window>preference>android>builde
然后打开cmd
进入下面的路劲
敲入
获得md5码
进入google网站注册,把你的md5码填进去
https://developers.google.com/maps/documentation/android/maps-api-signup
生产的key用记事本记起来
在xml文件中,引入 <com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0oSMQIkVrCH2-x7f7MiHuQJUNXQ8H9m0pPUzQ6Q"
/>
在主activity extends MapActivity
在AndroidManifest.xml中加上<uses-permission android:name="android.permission.INTERNET"/>
在application节点下,加入 <uses-library android:name="com.google.android.maps"/>
下面的代码是实现地图的定位,街景,交通地图,卫星地图切换
package com.googlemap.activity;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends MapActivity {
private MapView mapview;
private MapController control;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapview=(MapView) this.findViewById(R.id.mapview);
control=mapview.getController();
mapview.setClickable(true);
mapview.setTraffic(true);
mapview.setBuiltInZoomControls(true);
control.setZoom(10);
mapview.setLongClickable(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1, 1, 1, "交通地图");
menu.add(2, 2, 2, "卫星地图");
menu.add(3,3,3,"街景模式");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
mapview.setTraffic(true);
mapview.setSatellite(false);
mapview.setStreetView(false);
break;
case 2:
mapview.setTraffic(false);
mapview.setSatellite(true);
mapview.setStreetView(false);
break;
case 3:
mapview.setTraffic(false);
mapview.setSatellite(false);
mapview.setStreetView(true);
default:
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
public void UpdataMapshow(Double lat,Double lng){
int latI=(int) (lat*1E6);
int lngI=(int) (lng*1E6);
GeoPoint point=new GeoPoint(latI, lngI);
control.setCenter(point);
control.setZoom(mapview.getZoomLevel()-1);
control.animateTo(point);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0oSMQIkVrCH2-x7f7MiHuQJUNXQ8H9m0pPUzQ6Q" />
</LinearLayout>
- 大小: 7.5 KB
- 大小: 8.5 KB
- 大小: 6 KB
分享到:
相关推荐
Android Google map使用,Android Google map使用
googlemap使用
Google Map API 使用示例
google map 的应用实例,可以使用离线地图,很实用
Google Map API 接口调用。
Google Map MarkerCluster使用簡介 可使用此方式使marker自動表現群聚 相當的方便!
GoogleMap谷歌地图demo,调用GoogleMap api 实现的功能全面的地图工具
Google mapGoogle mapGoogle mapGoogle mapGoogle mapGoogle mapGoogle map
googleMap__谷歌___地图_.ppt
googleMap根据经纬度获取地理位置,里面有使用代码,只需填入经纬度即可获取地理位置信息
该实例实现google map和ExtJs结合开发,实现图层管理、图层可见性控制、图层要素详细信息查看等功能。
包括 使用文档和例子供大家参考 [removed][removed] [removed][removed] [removed] var gmap = null; var dynMapOv = null; function initialize() { //Load Google Maps gmap = new GMap2(document....
安卓 android google map 谷歌地图
谷歌地图Google Map API中文开发文档 V3
使用google map的API开发的LBS小软
google mapgoogle mapgoogle mapgoogle mapgoogle mapgoogle map
GoogleMap 开发源码
google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档google map api 参考文档
谷歌MAP_V3中文详解以及一个简单例子
GoogleMap控件是一款开源控件。 下载