`
chengfengyang
  • 浏览: 21121 次
社区版块
存档分类
最新评论

mars老师的googleMap(一)

阅读更多
一、申请 Apikey Apikey Apikey Apikey ,并放在正确的位置
这个应该都知道,但是是申请得到的 key 放哪里很多人不知道,可以放在
1 、 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="01Yu9W3X3vbpYT3x33chPXXX7U1Z6jy8WYZXNFA"
/>
2 、 java 中
mMapView = new MapView(this, "01Yu9W3X3vbpYT3x33chPxxx7U1Z6jy8WYZ
二、记得导入 uses-library uses-library uses-library uses-library
由于 1.0 版本的修改,使得 map 包不再是默认的了,使用的时候需要在 manife
点下加入
<uses-library android:name="com.google.android.maps" />
否则,你将遇到可恶的 “ java.lang.NoClassDefFoundError: ” ,切记!
三、需要给予一定的权限
因为要使用 GoogleMAP 的 service ,所以需要
<uses-permission android:name="android.permission.INTERNET"></uses-permissio
如果需要 GPS 等应用,还需要
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
四、 Activity Activity Activity Activity 需要继承自 MapActivity MapActivity MapActivity MapActivity
类似如下代码;
代码 : 全选
package com.iceskysl.showmap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class ShowMap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics