3
A
回答
2
1
爲找到當前位置使用全球定位系統。你可以得到更多的例子,併爲標記看到這個鏈接。 https://github.com/jgilfelt/android-mapviewballoons
0
我們這裏有幾個簡單的步驟
class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);
//---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), R.drawable.pin);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);
return true;
}
}
ABV代碼後,打電話給你的標記
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapView);
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
try {
addresses = geocoder.getFromLocationName(getIntent().getStringExtra("address"), 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Address address = addresses.get(0);
double lng = address.getLongitude();
double lat = address.getLatitude();
p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(17);
//---Add a location marker---
MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();
mapView.invalidate();
}
希望我已經清除你一些什麼。保持微笑:)
相關問題
- 1. 如何找到用戶當前位置?
- 2. 查找當前位置到另一個位置的標題
- 3. 在當前位置獲取標記
- 4. 在當前位置添加標記
- 5. 如何使用OSM將標記放置在當前位置?
- 6. 如何在flex4的textArea中找到當前光標位置?
- 7. 如何找到該程序的當前位置突破
- 8. 如何在「@」當前位置
- 9. 獲取學位從當前位置到目標位置Android
- 10. 動畫標記當前位置上的位置改變
- 11. 當前位置標記(藍圈)
- 12. 將當前位置傳遞給標記
- 13. Android當前位置標記ID(姓名)
- 14. 當前位置拖動的標記
- 15. 顯示當前位置標記出庫
- 16. 如何動態更改位置並記錄該位置javascript PHP
- 17. 谷歌地圖API如何設置當前位置標記
- 18. 如何分配當前地理座標以繪製從當前位置到目標位置的路徑?
- 19. 如何找到iphone的當前位置並更新它
- 20. 如何查找我當前位置附近的位置?
- 21. 查找當前位置
- 22. 找出當前位置
- 23. 在異步任務onPostExecution後在當前位置繪製標記
- 24. jquery - 我如何找到當前光標位置
- 25. Android位置 - 如何獲取當前位置並避免nullpointerexception
- 26. 從標記標題中的當前位置Android設置地址(位置名稱)
- 27. 如何找到從當前位置到給定位置的距離?
- 28. 查找當前位置的座標並找出國家
- 29. 核心位置未找到當前位置
- 30. 如何查找當前位置列表中最近的位置座標?
請添加什麼,你有沒有嘗試到現在? – PravinCG
http://developer.android.com/guide/tutorials/views/hello-mapview.html看到這個你可能會想法 – Abhi