最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android Map新用法:MapFragment應用介紹

 更新時間:2013年01月06日 17:16:19   投稿:whsnow  
MapView ,MapActivity 這種的局限在于,必須要繼承MapActivity,否則無法使用MapView,但是,MapFragment 這種的局限在于,必須要安裝Google Play Service ,也就是說必須是原生rom。而且sdk要在12以上

1.MapView ,MapActivity 這種的局限在于,必須要繼承MapActivity,否則無法使用MapView。糾結(jié)就在于此。但是,最新官網(wǎng)上已經(jīng)棄用了這糟粕的MapActivity。

Version 1 of the Google Maps Android API as been officially deprecated as of December 3rd, 2012. This means that from March 3rd, 2013 you will no longer be able to request an API key for this version. No new features will be added to Google Maps Android API v1. However, apps using v1 will continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.

2.MapFragment 這種的局限在于,必須要安裝Google Play Service ,也就是說必須是原生rom。而且sdk要在12以上。

3.WebView 貌似很輕松的集成進來,但沒有實踐就木有發(fā)言權(quán)。
第一種方式我先略過了。大家都知道。說第二種,第三種會了再補上
MapFragment是剛出的google官方包,要集成進來還是挺麻煩的。官網(wǎng)鏈接 https://developers.google.com/maps/documentation/android/start
首先要到google conlose 添加api access權(quán)限,拿到apikey,創(chuàng)建一個project ,然后到services里把Google Maps Android API v2打開,再到api access里把你的project的keystore的SHA1和包名填進去,拿到唯一的api key
打開sdk manager--在Extras里把Android Support Libaray 和 Google Play Services都安裝,lib和samples都在sdk_path/extra/google/google_play_services下。導入../lib_project作為自己項目的libaray
這一步完了之后在manifest.xml文件里添加權(quán)限和api key。代碼如下

復制代碼 代碼如下:

<permission
android:name="com.example.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>

com.example替換成自己project的package
復制代碼 代碼如下:

<uses-permission android:name="com.example.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!--My Location-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!--Maps API needs OpenGL ES2.0.-->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

放在application聲明里
復制代碼 代碼如下:

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="appkey"/>

在layout xml里加入MapFragment聲明
復制代碼 代碼如下:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>

activity不變,extends Activity就可以了。 不需要繼承MapActivity了。
注意,debug狀態(tài)下是不可以顯示地圖的,一定要在正式簽名下map才會顯示出來。
install下應該就能看到map了

還有不懂的就多看看官方文檔把,介紹的很清楚。以上只是方便我自己記憶。

相關文章

最新評論

长沙县| 广元市| 太白县| 泸州市| 沾化县| 江口县| 泽库县| 沂源县| 得荣县| 定结县| 庆云县| 马山县| 宜川县| 昭平县| 建德市| 清苑县| 子长县| 边坝县| 丰镇市| 汨罗市| 克东县| 陆河县| 宁武县| 东光县| 西城区| 简阳市| 岳西县| 淮北市| 延寿县| 房山区| 孟连| 福贡县| 河北省| 那坡县| 台北市| 竹溪县| 宜丰县| 无极县| 嫩江县| 博乐市| 庐江县|