我是新到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