在Android中,如何获得当前位置,并使用GPS无需在程序给予任何位置地图跟踪? [英] In ANDROID, How to get a current position and tracking in map using GPS without giving any location in a program?

查看:126
本文介绍了在Android中,如何获得当前位置,并使用GPS无需在程序给予任何位置地图跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新到Android,任何人都可以帮我要我的问题....
如何获得利用GPS在地图中查看当前位置和跟踪无程序给予任何位置?????

I am new to android, can anyone help me for my question.... How to get a current position and tracking in map using GPS without giving any location in a program?????

推荐答案

您想讨巧!使用 MyLocationOverlay 对象。 ;您可以通过调用方法 getLastFix()获取当前位置。要启用跟踪使用 enableMyLocation()。这个对象添加到您需要将它添加到您的地图叠加地图。

You want the easy way out ! Use MyLocationOverlay object. you can get the current location by calling the method getLastFix(); . To enable tracking use enableMyLocation(). To add this object to the map you need to add it to your map overlays.

MyLocationOverlay currLoc=new MyLocationOverlay(context,mapKey);
mapView.getAllOverlays.add(currLoc);
currLoc.enableMyLocation();
Location myLastLocation=currLoc.getLastFix();
currLoc.enableCompass();

一定要确保,在的onPause()你这样做:

currLoc.disableMyLocation();  //to save battery.

您可以通过调用 currLoc.enableMyLocation()恢复在 onResume)更新(;

you can resume updates in onResume() by calling currLoc.enableMyLocation();

这是我能找到的最简单的方法!它是相当准确的太

This is the easiest way I could find! and it is quite accurate too

这篇关于在Android中,如何获得当前位置,并使用GPS无需在程序给予任何位置地图跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆