當前位置:首頁 » 安卓系統 » android高德地圖api

android高德地圖api

發布時間: 2022-06-29 12:19:06

A. android textview如何顯示在高德地圖的api上方

樓主你好,我一直都在使用騰訊地圖強大給力功能,出門必備神器:.限行提醒:最智能的限行提醒,尾號、路段、地區均可提醒,再也不擔心被拍.學校提醒:導航中提醒前方學校,關愛兒童安全,文明駕車出行.搜索糾錯功能電子眼顯示更清晰:導航中電子眼顯示在地圖上,看得更清開的更穩

B. 安卓使用高德地圖API定位時,getBestProvider能返回gps,然而我再初始化location時,卻總是失敗

droid2.2,年後回升到2.3.M9屏幕解析度:960×640(目前只有iphone4可以達到,叫做視網膜屏)。電容式觸摸屏,最多支持10點觸摸。CPU:SamsungS5PC110(蜂鳥)(1GHz主頻)採用45納米工藝,該CPU基於CORTEX-A8架構,內置了2D/3D圖形加速器,可以支持復雜的3DUI以及大型游戲,結合32KB資料及32KB指令緩存,並且配備512KB的L2緩存,系統運行能力極強。HTCG71GHz的Snapdragon處理器主屏解析度:480×800像素操作系統:GoogleAndroid2.1Defy(型號:摩托羅拉ME525)800MHzOMAP3610處理器2GBROM和512MBRAM空間對於其他Android手機來說,Defy的性能仍處於一流水準。在對屏幕多點觸摸功能測試中,Defy的屏幕也經受住了考驗,並未出現什麼缺陷約合3300元人民幣MileStone480×854像素AndroidOSv2.0512MBROM+256MBRAM總體來看,M9和defe的都還可以,目前我在關注M9,從價格來說,他在2499到2699,性價比還可以,從性能來說,表現非常突出,我個人還是喜歡M9(目前的是iphone3GS),因為他更適合中國人的使用習慣,至於有些人說M9差的,我不知道他對手機了解多少,我也不知道M9差在哪裡,還請那幾位高手賜教。

C. 如何調用高德地圖api

先要去注冊一個高德平台賬號,然後創建一個應用,可以拿到一個appkey。通過這個appkey 在java裡面用http請求他的介面就可以拿到信息了,返回的應該是json格式的數據吧。他的介面文檔平台上面有。

D. android開發如何用高德地圖進行模擬定位.

一、 要實現高德地圖定位呢,首先需要做好以下幾步准備:
1. 在高德開放平台注冊帳號

2. 在開發中下載Android平台下的地圖SDK和定位SDK文件
進入相關下載下載自己想要的功能或文件,圖只是截取了地圖SDK的頁面,定位SDK也是一樣,按自己想要的文件下載。下載完成後解壓得到:
- 3D地圖包解壓後得到:3D地圖顯示包「AMap_3DMap_VX.X.X_時間.jar」和庫文件夾(包含armeabi、arm64-v8a等庫文件)。
- 2D地圖包解壓後得到:2D地圖顯示包「AMap_2DMap_VX.X.X_時間.jar 」
- 定位SDK下載並解壓得到定位包「AMap_Location_V2.x.x.jar「
3. 添加jar包,將jar包放入工程的libs目錄下。

對於每個jar文件,右鍵-選擇Add As Library,導入到工程中。或者使用菜單欄 選擇 File ->Project Structure->Moles-> Dependencies。點擊綠色的加號選擇File dependency. 然後選擇要添加的jar包即可,此時build.gradle中會自動生成如下信息。

創建自己的應用(創建過程內需要的SHA1已經的博客講過)

開發環境已經配置好了,接下來就是敲代碼了。
二、 首先我們要做的就是將地圖顯示出來,通過以下幾步操作,即可在應用中使用高德地圖SDK:
第一步:添加用戶key 在工程的「 AndroidManifest.xml 」文件如下代碼中添加您的用戶 Key。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"

android:theme="@style/AppTheme">
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="" />123456789

第二步:添加所需許可權 在工程的「 AndroidManifest.xml 」文件中進行添加。
//地圖包、搜索包需要的基礎許可權

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

//定位包、導航包需要的額外許可權(註:基礎許可權也需要)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />1234567891011121314

第三步:在布局xml文件中添加地圖控制項。
<com.amap.api.maps2d.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />1234

第四步,創建地圖Activity,管理地圖生命周期。
public class MainActivity extends Activity {
private MapView mMapView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//獲取地圖控制項引用
mMapView = (MapView) findViewById(R.id.map_view);
//在activity執行onCreate時執行mMapView.o

mMapView.onCreate(savedInstanceState);
}
@Override
protected void onDestroy() {
super.onDestroy();
//在activity執行onDestroy時執行mMapView.onDestroy(),實現地圖生命周期管理
mMapView.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
//在activity執行onResume時執行mMapView.onResume (),實現地圖生命周期管理
mMapView.onResume();
}
@Override
protected void onPause() {
super.onPause();
//在activity執行onPause時執行mMapView.onPause (),實現地圖生命周期管理
mMapView.onPause();
}
@Override

protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
//在activity執行onSaveInstanceState時執行mMapView.onSaveInstanceState (outState),實現地圖生命周期管理
mMapView.onSaveInstanceState(outState);
}

}

注意:一定要有mMapView.onCreate(savedInstanceState);
第二步:啟動定位功能:
1. 在主線程中獲得地圖對象AMap,並設置定位監聽且實現LocationSource介面:

public class MainActivity extends Activity implements LocationSource{1
if (aMap == null) {
aMap = mMapView.getMap();
//設置顯示定位按鈕 並且可以點擊
UiSettings settings = aMap.getUiSettings();
aMap.setLocationSource(this);//設置了定位的監聽,這里要實現LocationSource介面
// 是否顯示定位按鈕
settings.setMyLocationButtonEnabled(true);
aMap.setMyLocationEnabled(true);//顯示定位層並且可以觸發定位,默認是flase
}123456789
2. 配置定位參數,啟動定位

//初始化定位

mLocationClient = new AMapLocationClient(getApplicationContext());
//設置定位回調監聽,這里要實現AMapLocationListener介面,AMapLocationListener介面只有onLocationChanged方法可以實現,用於接收非同步返回的定位結果,參數是AMapLocation類型。
mLocationClient.setLocationListener(this);
//初始化定位參數
mLocationOption = new AMapLocationClientOption();
//設置定位模式為Hight_Accuracy高精度模式,Battery_Saving為低功耗模式,Device_Sensors是僅設備模式
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//設置是否返回地址信息(默認返回地址信息)
mLocationOption.setNeedAddress(true);
//設置是否只定位一次,默認為false
mLocationOption.setOnceLocation(false);
//設置是否強制刷新WIFI,默認為強制刷新
mLocationOption.setWifiActiveScan(true);
//設置是否允許模擬位置,默認為false,不允許模擬位置
mLocationOption.setMockEnable(false);
//設置定位間隔,單位毫秒,默認為2000ms
mLocationOption.setInterval(2000);
//給定位客戶端對象設置定位參數
mLocationClient.setLocationOption(mLocationOption);
//啟動定位
mLocationClient.startLocation();

高精度定位模式:
在這種定位模式下,將同時使用高德網路定位和GPS定位,優先返回精度高的定位

低功耗定位模式:
在這種模式下,將只使用高德網路定位

僅設備定位模式:
在這種模式下,將只使用GPS定位。

3. 實現AMapLocationListener介面,獲取定位結果:

public class MainActivity extends Activity implem

@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
//定位成功回調信息,設置相關消息
aMapLocation.getLocationType();//獲取當前定位結果來源,如網路定位結果,詳見官方定位類型表
aMapLocation.getLatitude();//獲取緯度
aMapLocation.getLongitude();//獲取經度
aMapLocation.getAccuracy();//獲取精度信息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
df.format(date);//定位時間
aMapLocation.getAddress();//地址,如果option中設置isNeedAddress為false,則沒有此結果,網路定位結果中會有地址信息,GPS定位不返回地址信息。
aMapLocation.getCountry();//國家信息
aMapLocation.getProvince();//省信息
aMapLocation.getCity();//城市信息
aMapLocation.getDistrict();//城區信息
aMapLocation.getStreet();//街道信息
aMapLocation.getStreetNum();//街道門牌號信息
aMapLocation.getCityCode();//城市編碼
aMapLocation.getAdCode();//地區編碼

// 如果不設置標志位,此時再拖動地圖時,它會不斷將地圖移動到當前的位置
if (isFirstLoc) {
//設置縮放級別
aMap.moveCamera(CameraUpdateFactory.zoomTo(17));
//將地圖移動到定位點
aMap.moveCamera(CameraUpdateFactory.changeLatLng(new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude())));
//點擊定位按鈕 能夠將地圖的中心移動到定位點
mListener.onLocationChanged(aMapLocation);
//獲取定位信息
StringBuffer buffer = new StringBuffer();
buffer.append(aMapLocation.getCountry() + ""
+ aMapLocation.getProvince() + ""
+ aMapLocation.getCity() + ""
+ aMapLocation.getProvince()
+ aMapLocation.getDistrict() + ""
+ aMapLocation.getStreet() + ""
+ aMapLocation.getStreetNum());
Toast.makeText(getApplicationContext(), buffer.toString(), Toast.LENGTH_LONG).show();
isFirstLoc = false;
}
} else {
//顯示錯誤信息ErrCode是錯誤碼,errInfo是錯誤信息,詳見錯誤碼表。
Log.e("AmapError", "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
Toast.makeText(getApplicationContext(), "定位失敗", Toast.LENGTH_LONG).show();
}
}
}3839404142434445464748495051
4.關於停止定位

@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
//mLocationClient.stopLocation();//停止定位
mLocationClient.onDestroy();//銷毀定位客戶端。
//銷毀定位客戶端之後,若要重新開啟定位請重新New一個AMapLocationClient對象。
}

//激活定位
@Override
public void activate(OnLocationChangedListener onLocationChangedListener) {
mListener = onLocationChangedListener;
}

@Override
public void deactivate() {
mListener = null;
}12345678910111213141516171819

E. android studio中高德地圖api定位小藍點怎麼設置

根據問題 分析給出解決方案:
嘗試通過getLastKnownLocation獲取上次定位信息
開啟network和gps監聽
獲得network定位信息location
比較當前location和新獲取的location哪個更好(來自network)
獲得gps定位信息location
停掉network監聽
比較當前location和新獲取的location哪個更好(來自gps)
如果gps伺服器丟失,重新開啟network監聽

F. 高德地圖,android開發中,怎麼用經緯度來顯示地圖

首先創建工程,並在工程Build Path>Configure Build Path…>libraries 中選擇「Add Externel JARs…」,選定

MapApi.jar,點擊OK,這樣就可以將高德地圖Android API 庫文件引入。然後在工程Build Path>Configure Build

Path…>Order and Export 中將引入的庫文件MapApi.jar 選中,點擊OK,這樣您就可以在您的程序中使用高德地圖API

了。

二、我們在不熟悉的情況下、先盡量多的添加此軟體應用許可權;所以在mainifest中添加如下代碼;插入的位置在

<application的代碼之前。

Java代碼
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>

三、接著就要在res文件下的layout中添加界面布局了。其代碼如下、你可以完全復制進去。

Java代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--添加文本輸入框,查找地址-->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content" android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="經度"/>
<EditText android:layout_height="fill_parent"
android:layout_width="100px"
android:id="@+id/longitude"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="緯度"/>
<EditText android:layout_height="fill_parent"
android:layout_width="100px"
android:id="@+id/latitude"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查找"
android:id="@+id/button"/>
</LinearLayout>

<com.amap.mapapi.map.MapView android:id="@+id/mapView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:clickable="true"
/>
</LinearLayout>

四、最後就是軟體的主程序部分了、裡面需要的類和方法不多,主要以按鈕的監聽器和地圖的界面實現為主

Java代碼
public void onCreate(Bundle savedInstanceState) {
// this.setMapMode(MAP_MODE_VECTOR);//設置地圖為矢量模式

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setBuiltInZoomControls(true); // 設置啟用內置的縮放控制項
mMapController = mMapView.getController(); // 得到mMapView
// 的控制權,可以用它控制和驅動平移和縮放
point = new GeoPoint((int) (39.982378 * 1E6), (int) (116.304923 * 1E6)); // 用給定的經緯度構造一個GeoPoint,單位是微度(度*
// 1E6)
// 按鈕添加監聽器
button_location = (Button) findViewById(R.id.location);
longitude = (EditText) findViewById(R.id.longitude);
latite = (EditText) findViewById(R.id.latitude);
locationListener = new OnClickListener() {
public void onClick(View e) {
if (e.equals(button_location)) {
// 得到文本輸入框的中經緯 度坐標值
String latStr = longitude.getText().toString();
// 將得到的字元串轉成數值
double lat = Integer.parseInt(latStr);
String lngStr = latite.getText().toString();
double lng = Integer.parseInt(lngStr);
//轉成經緯度坐標
lat=lat*1E6;
lng=lng*1E6;
// 用給定的經緯度構造一個GeoPoint,單位是微度(度*1E6)
point = new GeoPoint((int) (lat), (int) (lng));
mMapController.setCenter(point); // 設置地圖中心點
mMapController.setZoom(12); // 設置地圖zoom 級別
// 添加地圖覆蓋物
// MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation(); // 判斷是否發現位置提供者
mylocTest.enableCompass(); // 打開指南針
mMapView.getOverlays().add(mylocTest);// 添加定位覆蓋物
}
}
};
// 按鈕添加監聽器
button_location.setOnClickListener(locationListener);
mMapController.setCenter(point); // 設置地圖中心點
mMapController.setZoom(12); // 設置地圖zoom 級別
// 添加地圖覆蓋物
mylocTest = new MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation(); // 判斷是否發現位置提供者
mylocTest.enableCompass(); // 打開指南針
mMapView.getOverlays().add(mylocTest);// 添加定位覆蓋物
}
//另外一個添加界面覆蓋物的類:

public class MyLocationOverlayProxy extends com.amap.mapapi.map.MyLocationOverlay{

private Location mLocation;
protected final Paint mPaint = new Paint();
protected final Paint mCirclePaint = new Paint();
private Bitmap gps_marker=null;
private Point mMapCoords = new Point();
private final float gps_marker_CENTER_X;
private final float gps_marker_CENTER_Y;
private final LinkedList<Runnable> mRunOnFirstFix = new LinkedList<Runnable>();
public MyLocationOverlayProxy(amap amap, MapView mMapView) {

super(amap, mMapView);
gps_marker = ((BitmapDrawable) amap.getResources().getDrawable(
R.drawable.marker_gpsvalid)).getBitmap();
gps_marker_CENTER_X = gps_marker.getWidth() / 2 - 0.5f;
gps_marker_CENTER_Y= gps_marker.getHeight() / 2 - 0.5f;
}

public boolean runOnFirstFix(final Runnable runnable) {
if (mLocation != null) {
new Thread(runnable).start();
return true;
} else {
mRunOnFirstFix.addLast(runnable);
return false;
}
}

public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
mLocation = location;
for(final Runnable runnable : mRunOnFirstFix) {
new Thread(runnable).start();
}
mRunOnFirstFix.clear();
super.onLocationChanged(location);
}

protected void drawMyLocation(Canvas canvas, MapView mapView, final Location mLocation,
GeoPoint point, long time) {
Projection pj=mapView.getProjection();
if (mLocation != null) {
mMapCoords=pj.toPixels(point, null);
final float radius = pj.metersToEquatorPixels(mLocation.getAccuracy());
this.mCirclePaint.setAntiAlias(true);
this.mCirclePaint.setARGB(35, 131, 182, 222);
this.mCirclePaint.setAlpha(50);
this.mCirclePaint.setStyle(Style.FILL);
canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, this.mCirclePaint);
this.mCirclePaint.setARGB(225, 131, 182, 222);
this.mCirclePaint.setAlpha(150);
this.mCirclePaint.setStyle(Style.STROKE);
canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, this.mCirclePaint);
canvas.drawBitmap(gps_marker, mMapCoords.x-gps_marker_CENTER_X, mMapCoords.y-gps_marker_CENTER_Y, this.mPaint);
}
}

}

G. android怎麼用高德api

高德地圖API V2 版本使用3D引擎,你的是模擬器,並且模擬器不支持GPU,你可以在模擬器上勾選一個模擬GPU的選項。 如果沒有的話,建議用真機調試。 另外:api官網上有技術支持群QQ,建議你加QQ群問。

H. 高德地圖Android api 未知主機 unknown_host是什麼原因

  1. 首先,您連上網了沒,你的設備或者模擬器。

  2. 你的KEY什麼的換好了嗎?一般要開發者賬號,官網注冊你的demoAPP的。

  3. 你要添加的service添加了沒?

    按著官方的教程走應該沒問題,自己看看是不是漏了什麼。

I. android 開發高德地圖api 衛星地圖怎麼設置

親,關於API開發問題,小德建議親可以在開發論壇發帖咨詢開發大神哦~

J. 高德地圖android API為什麼不能周期定位

在onResume()裡面激活定位,onLocationChanged(AMapLocation aLocation)方法里,會根據改變的經緯度重新來定位的額~

熱點內容
現在玩游戲的電腦需要什麼配置 發布:2024-04-20 17:09:57 瀏覽:194
游樂園的密碼一般為多少 發布:2024-04-20 17:09:51 瀏覽:40
興元安卓機怎麼進系統 發布:2024-04-20 17:07:16 瀏覽:805
我的世界伺服器如何放村民 發布:2024-04-20 17:05:35 瀏覽:358
手機反編譯dex 發布:2024-04-20 17:01:01 瀏覽:703
安卓怎麼設置微信拍一拍 發布:2024-04-20 16:44:48 瀏覽:568
三星3熱點密碼怎麼設置 發布:2024-04-20 16:30:52 瀏覽:578
用keil編譯顯示警告warn 發布:2024-04-20 16:27:09 瀏覽:893
訪問在哪兒 發布:2024-04-20 16:20:42 瀏覽:200
安卓手機有什麼可以把聲音改成電音的軟體 發布:2024-04-20 16:19:40 瀏覽:563