1. 程式人生 > >Android定位&地圖&導航——基於百度地圖實現的定位功能

Android定位&地圖&導航——基於百度地圖實現的定位功能

public class MyApplication extends Application{
    public LocationClient mLocationClient = null;
    public GeofenceClient mGeofenceClient;
    public MyLocationListenner myListener = new MyLocationListenner();
    public static String TAG = "MyApplication";
    private static MyApplication mInstance = null
; @Override public void onCreate(){ mInstance = this; mLocationClient = new LocationClient(this); /** * 專案的key,自己到官網申請 http://lbsyun.baidu.com/apiconsole/key */ mLocationClient.setAK("你的應用Key"); mLocationClient.registerLocationListener(myListener); mGeofenceClient
= new GeofenceClient(this); super.onCreate(); Log.d(TAG, "... Application onCreate... pid=" + Process.myPid()); } public static MyApplication getInstance(){ return mInstance; } /** * 停止定位 */ public void stopLocationClient(){
if (mLocationClient != null && mLocationClient.isStarted()){ mLocationClient.stop(); } } /** * 發起定位 */ public void requestLocationInfo(){ setLocationOption(); if (mLocationClient != null && !mLocationClient.isStarted()){ mLocationClient.start(); } if (mLocationClient != null && mLocationClient.isStarted()){ mLocationClient.requestLocation(); } } /** * 設定百度地圖的相關引數 */ private void setLocationOption(){ LocationClientOption option = new LocationClientOption(); option.setOpenGps(true); // 開啟gps option.setCoorType("bd09ll"); // 設定座標型別 option.setServiceName("com.baidu.location.service_v2.9"); option.setPoiExtraInfo(true); option.setAddrType("all"); option.setPoiNumber(10); option.disableCache(true); mLocationClient.setLocOption(option); } /** * 監聽函式,有更新位置的時候,格式化成字串,輸出到螢幕中 */ public class MyLocationListenner implements BDLocationListener { @Override public void onReceiveLocation(BDLocation location){ if (location == null){ sendBroadCast("定位失敗!"); return; } sendBroadCast(location.getAddrStr()); } public void onReceivePoi(BDLocation poiLocation){ if (poiLocation == null){ sendBroadCast("定位失敗!"); return; } sendBroadCast(poiLocation.getAddrStr()); } } /** * 得到傳送廣播 * @param address */ public void sendBroadCast(String address){ stopLocationClient(); Intent intent = new Intent(MainActivity.LOCATION_BCR); intent.putExtra("address", address); sendBroadcast(intent); } }

相關推薦

Android定位&地圖&導航——基於地圖移動獲取位置和自動定位

public class MainActivity extends Activity { public MyApplication app; static MapView mMapView = null; public MKMapViewListener mMapListen

Android定位&地圖&導航——基於地圖實現定位功能

public class MyApplication extends Application{ public LocationClient mLocationClient = null; public GeofenceClient mGeofenceClient; publi

Android定位&地圖&導航——基於地圖實現自定義圖示繪製並點選時彈出泡泡

public class MainActivity extends Activity { private EditText txtAddr; // 定位相關 LocationClient mLocClient; LocationData locData = nul

Android開發-基於地圖API開發仿滴滴出行APP介面的實現

前 言 近年來,由於移動網際網路快速的發展以及基於移動裝置的APP的普及,移動網際網路改變了人們的生活方式。從線上的電子支付到線下的出行,移動網際網路是當今社會人們生活不可或缺的一部分,而線下出行的網約車的出現極大便利了人們的出行,雖然它飽受了很大的爭議,但不可否認的是網約車的出現是

2016基於地圖定位

現在百度改版後有點不習慣,沒辦法,只有自己又去看了一下,比以前的簡單方便多,有時間我會把導航等給做出來,當然了這個程式碼只是對於初學者來的,因為我自己也是初學者,你自己也可以在百度API上去看,試著寫一遍,我這個主要的目的還是因為最近需要我才弄了一個定位的東西提

基於地圖開發網易班車地圖導航展示

col uri type open one 記錄 length () 代碼 來到網易已經不知不覺一兩個月了,最近把原來租的房子出租後,打算重新租一套房子。找到一個好房子不容易,首先考慮交通問題,上下班時間不能耗費太長,網易提供了遍布全城的班車系統,不過說實話,貌似只有文字說

基於地圖SDK和Elasticsearch GEO查詢的地理圍欄分析系統(3)-前端實現

方便 復制 類型 復制代碼 自動跳轉 rar 窗口 stack delete 轉載自:http://www.cnblogs.com/Auyuer/p/8086975.html MoonLight可視化訂單需求區域分析系統實現功能:   在現實生活中,計算機和互聯網迅速發展,

基於地圖API刪除指定的覆蓋物

引用百度地圖API過程中,想刪除指定的覆蓋物,有很多很多的坑。什麼clearOverlay()方法,直接給我所有覆蓋物都給乾沒了。還有網上介紹的removeOverlay(物件),這種又介紹不清楚,然後自己經過實踐,最終解決了。 直接上圖、上程式碼。 查詢所有地圖的覆蓋物程式碼: /

基於地圖API的WinForm地圖

      大概去年的這個時候,我用VB寫了一個百度地圖的Demo,使用了webBrowser載入本地網頁的方式,只是限於當時的技術,好多功能都沒實現,昨天,我重新對這個程式進行了編寫,這一次我使用的是C#。在正式開始之前,先來解決幾個問題。       一、地圖    

Android程式打包後,地圖key驗證失敗解決辦法

今天在對專案進行打包簽名,通過apk安裝到手機上後,忽然發現百度地圖無法使用了,思前想後,終於找到了原因。 我們在呼叫百度地圖api需要通過SHA1+“,”+包名的方式獲取百度地圖Key,而在專案除錯階段我們一般使用的都是使用Eclipse的除錯簽名,但是當專案真正上線之

基於地圖SDK整合的一些功能

最近開發的專案用到了地圖,並在地圖上顯示某些座標位置的標記圖示,點選圖示來顯示此座標處的一些資訊,之後我從百度地圖卡房平臺下載了百度地圖的SDK和Demo,並結合API總結了一下幾點內容,實現了下面的幾個功能: (1)最基本功能,定位到當前位置 並獲

一個基於地圖的桌面軟體(附工程原始碼)

光陰似箭,日月如梭,恍然間,2013就這樣平平淡淡的過去了。想想工資卡上的餘額,心中不免浮起蛋蛋的憂桑。如果再回到2013。。。。。罷了,青春就是如此,每個人都肆無忌憚的揮霍著,在年華正當之時。或許只有當歲月的烙印狠狠落下的那一刻,我們才會想起那再也回不去的美好年華,那落英

iOS基於地圖的開發(1)——使用者當前位置

首先需要設定mapView的屬性: self.mapView = [[[BMKMapView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] aut

Android開發 用AndroidStudio開發地圖Demo時的經典錯誤230的另一種可能

Authentication Error errorcode: 230 uid: -1 appid -1 msg: APP Scode碼校驗失敗 令人眼紅的字眼,這個神奇的錯誤折騰了我一晚上,一切都是

基於地圖做動態路線打點

// 百度地圖API功能 // 百度地圖獲取容器 var mp = new BMap.Map("allmap"); // 百度地圖定義中心點 mp.centerAndZoom(new BMap.Point(116.3964,39.9093), 15); //

Android Studio地圖開發(地圖

第一步、配置環境 1.申請百度地圖key 首先到百度地圖開放平臺,登入賬號,然後到如下介面 點選“建立應用”,到如下介面,填寫應用名稱,應用型別選擇“Android SDK” 獲取釋出版SHA1和開發版SHA1,連結如下百度提供的獲取SHA1的方法,注

隱藏 google 地圖 Logo 隱藏 地圖 Logo

隱藏 blog col -s container pan event contain first Google 地圖 var isFirstLoad=true; //地圖瓦片加載完成之後的回調 google.maps.event.addListener(map, ‘til

地圖】在地圖上框出邊界線

程式碼: 一、建立地圖 建立地圖物件;設立中心點以及地圖級別。 var map = new BMap.Map("container"); map.centerAndZoom(new BMap.Point(116.403765, 39.914850), 12); 二、新增地圖事件

地圖開發之——地圖鷹眼軌跡管理臺DEMO-v3部署到伺服器上

百度地圖開發官方下載口:https://github.com/baidu-openmap-trace/web-demo-v3 第一:部署準備 搭建NPM和FIS3的環境 1、安裝node.js:https://nodejs.org/en/ 點選版本下載,然後就安裝

地圖API之地圖退拽標記點獲取經緯度的實現程式碼

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />