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

高德地圖android

發布時間: 2022-02-04 17:40:29

❶ 高德地圖,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);
}
}

}

❷ 高德android導航開發,要怎麼自定義路線

定義不了。高德導航和高德地圖的真正區別在於。
1高德導航專用於行車打造的,可以離線搜索,離線導航,也可以在線導航,搜索更新的POI,高德地圖只能在線導航,在線搜索。
2.導航是收費,高德地圖是免費,用於步行,公交換乘比較方便。其實現在高德地圖對駕駛導航一樣的方便好用。
3.高德導航不費流量,高德地圖現在都是本地離線地圖,流量可以忽略不計。
4.高德導航和高德地圖是兩個部門開發的。

❸ android手機 高德導航地圖放哪個目錄下

1、在自己的手機桌面上,找到高德地圖並點擊進入。

❹ android高德地圖怎麼由城市名稱設置位置

第一步,我們需要下載SDK
第二步,解壓後,將jar包放進libs文件夾中,並加入環境變數中。

第三步,在AndroidManifest.xml文件中配置許可權:
<!--用於進行網路定位-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!--用於訪問GPS定位-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!--用於獲取運營商信息,用於支持提供運營商信息相關的介面-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--用於訪問wifi網路信息,wifi信息會用於進行網路定位-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--用於獲取wifi的獲取許可權,wifi信息會用來進行網路定位-->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<!--用於訪問網路,網路定位需要上網-->
<uses-permission android:name="android.permission.INTERNET"/>
<!--用於讀取手機當前的狀態-->

❺ android 怎麼確定高德地圖導航

如果是想在自己的app自帶導航界面,就接入高德地圖sdk。

如果想從自己app開啟高德地圖app導航,那就上代碼:

//高德地圖,起點就是定位點

//終點是LatLngll=newLatLng("你的緯度latitude","你的經度longitude");

publicvoidstartNaviGao(){

if(isAvilible(getContext(),"com.autonavi.minimap")){

try{

//sourceApplication

Intentintent=Intent.getIntent("androidamap://navi?sourceApplication=公司的名稱(隨意寫)&poiname=我的目的地&lat="+ll.latitude+"&lon="+ll.longitude+"&dev=0");

startActivity(intent);

}catch(URISyntaxExceptione){

e.printStackTrace();

}

}else{

ToastUtil.showToast("您尚未安裝高德地圖或地圖版本過低");

}

}


❻ android 高德地圖的開發 移動地圖流暢性

這里不得不說下個人情況,此項目是他人開發,而開發人員已經不在公司,bug轉發給我了。自己之前也沒怎麼使用過高德,主要使用的是谷歌地圖和mapbox。在修改這個bug的時候,思緒會受谷歌api一些影響,因為一直覺得他們的api都差不多。現在我打開自己的頁面,然後拖動marker,拖動結束我會列印一下經緯度,然後把這個經緯度復制下來,並在高德的官方地圖上去搜索獲取到的這個經緯度。結果確實一直都是有偏差的,而且還偏差值每次都不同。

❼ android 百度地圖和高德地圖為什麼比自己開發的好那麼多

你用網路搜人家當然說網路地圖好了,
你用神馬搜索就會提示高德地圖好。
這個其實不用太在意,一般情況下這兩個軟體地圖都夠用,
你可以都試試感覺一下你用哪個更舒服些。

❽ android使用高德定位sdk獲取的城市名稱怎樣讓其他的界面進行調用

第一步,我們需要下載SDK
第二步,解壓後,將jar包放進libs文件夾中,並加入環境變數中。

第三步,在AndroidManifest.xml文件中配置許可權:
<!--用於進行網路定位-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!--用於訪問GPS定位-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!--用於獲取運營商信息,用於支持提供運營商信息相關的介面-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--用於訪問wifi網路信息,wifi信息會用於進行網路定位-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--用於獲取wifi的獲取許可權,wifi信息會用來進行網路定位-->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<!--用於訪問網路,網路定位需要上網-->
<uses-permission android:name="android.permission.INTERNET"/>
<!--用於讀取手機當前的狀態-->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!--用於寫入緩存數據到擴展存儲卡-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!--用於申請調用A-GPS模塊-->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>

並在application標簽中添加:
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="你申請的key" />
<service android:name="com.amap.api.location.APSService" />

第四步,測試代碼:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;

public class MainActivity extends AppCompatActivity {
//聲明AMapLocationClient類對象
public AMapLocationClient mLocationClient = null;
//聲明定位回調監聽器
public AMapLocationListener mLocationListener = new MyAMapLocationListener();
//聲明AMapLocationClientOption對象
public AMapLocationClientOption mLocationOption = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}

private void init() {
//初始化定位
mLocationClient = new AMapLocationClient(getApplicationContext());
//設置定位回調監聽
mLocationClient.setLocationListener(mLocationListener);
//初始化AMapLocationClientOption對象
mLocationOption = new AMapLocationClientOption();
//設置定位模式為AMapLocationMode.Hight_Accuracy,高精度模式。
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//獲取一次定位結果:
//該方法默認為false。
mLocationOption.setOnceLocation(false);

//獲取最近3s內精度最高的一次定位結果:
//設置setOnceLocationLatest(boolean b)介面為true,啟動定位時SDK會返回最近3s內精度最高的一次定位結果。如果設置其為true,setOnceLocation(boolean b)介面也會被設置為true,反之不會,默認為false。
mLocationOption.setOnceLocationLatest(true);
//設置是否返回地址信息(默認返回地址信息)
mLocationOption.setNeedAddress(true);
//設置是否允許模擬位置,默認為false,不允許模擬位置
mLocationOption.setMockEnable(false);
//關閉緩存機制
mLocationOption.setLocationCacheEnable(false);
//給定位客戶端對象設置定位參數
mLocationClient.setLocationOption(mLocationOption);
//啟動定位
mLocationClient.startLocation();

}

private class MyAMapLocationListener implements AMapLocationListener {

@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
Log.e("位置:", aMapLocation.getAddress());
} else {
//定位失敗時,可通過ErrCode(錯誤碼)信息來確定失敗的原因,errInfo是錯誤信息,詳見錯誤碼表。
Log.e("AmapError", "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
}
}
}
}
}

❾ 百度地圖和高德地圖android 哪個好用

當然是高德的啦,雖然網路的還行,但高德在地圖上比較專業所以選高德

❿ android studio高德地圖載入離線地圖如何做

一、注冊開發者賬號,新建新Key。
二、首先根據高德地圖開發者獲取key。
androidstudio獲取SHA1方法:打開androidstudio的Termina(alt+F12),輸入命令:keytool -v -list -keystore keystore文件路徑(默認路徑 C:\Users\用戶名\.android debug.keystore),默認密碼:android,即可獲取SHA1。
PackageName為app中build。gradle中的applicationId。
三、打開AndroidStudio-->Build-->Generate Signed APK-->Create new...,創建新的key,按照圖示創建即可,要記下Alias的名字和密碼,然後選擇第V2-->finish即可。
四、新建工程,將下載的SDK的jar包復制到工程libs下,並add as library(復制→粘貼到文件夾下即可)。
五、3D地圖需要添加so庫:在main目錄下創建jniLibs,將下載的so庫文件拷貝到這個目錄下。

熱點內容
舊電腦共享伺服器 發布:2024-04-27 06:32:21 瀏覽:338
java程序練習 發布:2024-04-27 06:24:00 瀏覽:437
sql30 發布:2024-04-27 06:22:10 瀏覽:54
怎樣防止sql注入 發布:2024-04-27 06:11:25 瀏覽:235
安卓為什麼不能登蘋果系統的游戲 發布:2024-04-27 06:11:23 瀏覽:600
編程日課 發布:2024-04-27 05:56:54 瀏覽:619
漏洞上傳工具 發布:2024-04-27 05:50:58 瀏覽:716
手機如何選擇存儲 發布:2024-04-27 05:40:25 瀏覽:799
機架式伺服器怎麼操作 發布:2024-04-27 05:19:02 瀏覽:815
我的世界minez網易伺服器 發布:2024-04-27 05:09:26 瀏覽:384