成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Android開發GoogleMap入門

移動開發 Android
開發基于谷歌地圖的應用和普通的android應用差不多都要使用它提供給我們的類庫,所不同的是google map的類庫不是android平臺的基本類庫,是google api的一部分,所以建立項目時,SDK要選擇Google APIs;還有一點,開發基于地圖的應用時候需要使用google map的APIkey,必須先申請key,然后才能開發基于地圖的應用。

Android開發要連接GoogelMaps使用MapView時需要,先從Google網站申請一組經過驗證的Maps API Key授權碼,這個在網上很多。

[代碼] [Java]代碼

  1. package com.android.antking.map; 
  2.     import com.google.android.maps.MapActivity; 
  3.     import com.google.android.maps.GeoPoint; 
  4.     import com.google.android.maps.MapController; 
  5.     import com.google.android.maps.MapView; 
  6.     import android.os.Bundle; 
  7.     public class MyMain extends MapActivity { 
  8.         //放大倍數 
  9.        static final int  INITIAL_ZOOM_LEVEL=12
  10.        //中心點 
  11.        static final int  INITIAL_LATITUDE=123465465
  12.        static final int  INITIAL_LONGITUDR=15634646
  13.         public void onCreate(Bundle savedInstanceState) { 
  14.             super.onCreate(savedInstanceState); 
  15.             setContentView(R.layout.main); 
  16.             MapView mapView = (MapView) findViewById(R.id.mapView); 
  17.             //enable to change the size of the map 
  18.             mapView.setBuiltInZoomControls(true); 
  19.             //設置Zoom 大小和地圖的中心點 
  20.             MapController mc = mapView.getController(); 
  21.             mc.setZoom(INITIAL_ZOOM_LEVEL); 
  22.             mc.setCenter(new GeoPoint(INITIAL_LATITUDE,INITIAL_LONGITUDR)); 
  23.         } 
  24.         @Override 
  25.         protected boolean isRouteDisplayed() { 
  26.             // TODO Auto-generated method stub 
  27.             return false
  28.         } 
  29.     } 

[代碼] [XML]代碼

  1. <?xml version="1.0" encoding="utf-8"?> 
  2.     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.         android:orientation="vertical" 
  4.         android:layout_width="fill_parent" 
  5.         android:layout_height="fill_parent" 
  6.         > 
  7.     <TextView  
  8.         android:layout_width="fill_parent" 
  9.         android:layout_height="wrap_content" 
  10.         android:text="@string/hello" 
  11.         /> 
  12.      <com.google.android.maps.MapView 
  13.           android:id="@+id/mapView" 
  14.           android:layout_width="fill_parent" 
  15.           android:layout_height="fill_parent" 
  16.           android:enabled="true" 
  17.           android:clickable="true" 
  18.           android:apiKey="0FZLYf-YM4SRrJrJum55MeeaO4Gd_IitVFmtUeA"/>這個是自己開發的google mapApi 密鑰 
  19.     </LinearLayout> 

[代碼] 在這里加上google的地圖包,還有Internet權限

  1. <?xml version="1.0" encoding="utf-8"?> 
  2.     <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  3.           package="com.android.antking.map" 
  4.           android:versionCode="1" 
  5.           android:versionName="1.0"
  6.         <uses-sdk android:minSdkVersion="7" /> 
  7.         <uses-permission android:name="android.permission.INTERNET"></uses-permission> 
  8.         <application android:icon="@drawable/icon" android:label="@string/app_name"
  9.             <activity android:name=".MyMain" 
  10.                       android:label="@string/app_name"
  11.                 <intent-filter> 
  12.                     <action android:name="android.intent.action.MAIN" /> 
  13.                     <category android:name="android.intent.category.LAUNCHER" /> 
  14.                 </intent-filter> 
  15.             </activity> 
  16.             <uses-library android:name="com.google.android.maps"></uses-library> 
  17.         </application> 
  18.     </manifest> 

1.創建工程,注意SDK旋轉為"Goolge APIs”

2.修改AndroidManifest.xml文件

由于使用Google Map API,所以必須添加<uses-library android:name="com.google.android.maps" />

由于需要從網絡獲取地圖數據,所以需要訪問網絡的權限<uses-permission android:name="android.permission.INTERNET"/>

可能還需要添加其他權限。

3.創建MapView

4.實現MapActivity

5.MapController的使用

6.Ovelay的使用

責任編輯:閆佳明 來源: oschina
相關推薦

2011-09-09 14:09:17

Android Wid

2013-01-16 14:41:14

Android開發Android SDK

2013-01-16 15:07:30

Android NDKAndroid開發

2009-03-11 13:18:57

Android入門Android開發Android模擬器

2013-05-20 15:42:22

2010-02-04 17:59:50

Android SDK

2010-02-06 15:31:18

ibmdwAndroid

2009-07-22 14:55:16

ibmdwAndroid

2013-01-10 13:50:25

Android開發組件

2013-01-16 17:34:32

Android開發路線圖

2013-01-17 16:17:33

Android開發Intent組件

2012-04-26 22:57:57

Android

2017-04-10 15:47:50

Android Stujni開發入門

2013-01-17 15:51:42

Android開發應用程序組件

2017-11-27 13:09:00

AndroidGradle代碼

2014-05-08 13:36:07

Android Wea開發者預覽版

2013-01-10 14:21:24

Android開發組件Activities

2010-07-02 09:54:32

Symbian開發

2012-01-10 09:56:32

WPF

2009-10-21 12:45:07

linux程序開發基礎入門
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 视频在线一区二区 | 一区二区中文字幕 | 国产精品久久久久aaaa九色 | 伊人免费在线观看 | 一级aaaa毛片 | 国产精品久久久久久久久久久免费看 | 91精品国产综合久久久动漫日韩 | 久久一区二区三区免费 | 国产精品不卡 | 亚洲成人网在线 | 亚洲午夜精品一区二区三区他趣 | 国产欧美在线一区 | 午夜视频一区二区三区 | 亚洲高清视频一区二区 | 国产精品夜夜春夜夜爽久久电影 | 亚洲一区中文字幕在线观看 | 国产精品日韩一区 | 91高清在线| 国产精品视频一区二区三 | 亚洲欧洲视频 | 免费人成在线观看网站 | 精品日韩电影 | 亚洲精品久久国产高清情趣图文 | 久久久久国产精品一区二区 | 欧美一级高潮片免费的 | 日本一区二区高清不卡 | 欧美一区两区 | 成人在线播放 | 欧洲性生活视频 | 毛片a级 | www.日韩系列 | 日日操日日干 | 久久在线| 久久草在线视频 | 国产伦精品一区二区三区高清 | 国产精品久久久久久吹潮 | 国产精品久久久久久久久久免费看 | 欧美亚洲视频在线观看 | 黄色一级大片在线免费看产 | 一起操网站 | 日本一区二区三区四区 |