0
A
回答
1
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.show3);
Dataset = (Gps_mapApplicationDataset) getApplicationContext();
dbHelper = Dataset.getDbHelper();
Dcalcuation = new DistanceCalculator();
mapview = (MapView) findViewById(R.id.show_mapview);
mapview.setSatellite(false);
mapview.setBuiltInZoomControls(true);
mapOverlays = mapview.getOverlays();
locMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (locMan.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0,
this);
curLocation = locMan
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Log.v("Gps", "on");
} else if (locMan.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
100, 0, this);
curLocation = locMan
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Log.v("network", "on");
} else {
Log.v("setting", "on");
final Intent poke = new Intent();
poke.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
poke.setData(Uri.parse("3"));
sendBroadcast(poke);
locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0,
this);
curLocation = locMan
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
if (curLocation != null) {
clat = curLocation.getLatitude();
clng = curLocation.getLongitude();
Log.v("TAG ", clat + " " + clng);
GeoPoint srcgeopoint = new GeoPoint((int) (clat * 1E6),
(int) (clng * 1E6));
Drawable marker = getApplicationContext().getResources()
.getDrawable(R.drawable.pin1);
mapview.getController().animateTo(srcgeopoint);
MapAddressOverlay itemizedOverlay = new MapAddressOverlay(marker);
itemizedOverlay.addOverlay(this, clat, clng);
mapview.getOverlays().add(itemizedOverlay);
mapview.invalidate();
} else {
Toast.makeText(new_map.this, "No Location Find", Toast.LENGTH_SHORT);
}
相關問題
- 1. 轉換位置爲GeoPoint
- 2. 如何將座標轉換爲geoPoint格式?
- 3. 地理位置:需要將「地名」轉換爲「規範地名」
- 4. 將Integer轉換爲Lat long地理位置
- 5. RegEx將特定模式v-q-替換爲q-並將v-替換爲q-。
- 6. IP地理位置轉換,如maxmind geoip
- 7. 將每位候選人格式轉換爲OpenSTV BLT格式
- 8. 位置SKSpriteNode在0,0?
- 9. 將字符串轉換爲Android Geopoint的int
- 10. Java算法將地圖座標轉換爲Google地圖格式
- 11. 程序將時間以秒爲單位轉換爲hh:mm:ss格式
- 12. GeoPoint和當前位置
- 13. 將字符串轉換爲格式爲
- 14. 如何將MSC號碼從HLR查找轉換爲地理位置?
- 15. 將SQL2008地理查詢轉換爲JPG
- 16. wiki格式文本轉換爲html的位置在哪裏?
- 17. 在java中將多個位置的本地dateTime轉換爲UTC
- 18. 將GPS座標轉換爲PDF地圖上的位置
- 19. 將C++位模式轉換爲Java
- 20. Fortran轉換爲Python格式
- 21. 如何將Latitud和Longitud轉換爲Google GeoPoint?
- 22. 如何將8位數字轉換爲日期格式
- 23. 將3位數字輸入轉換爲日期格式
- 24. 轉換爲貨幣格式
- 25. 轉換日期格式爲
- 26. 將標記中心設置爲GeoPoint
- 27. Twitter地理位置/搜索
- 28. 地理位置API爲Rails
- 29. 如何獲取地圖上單擊位置的地理位置?
- 30. 將xlsx轉換爲JSON格式?
發佈接收數據的一個示例。 – 2012-03-23 09:36:59