我正在使用地图视图,我想要的是标记所有前任。靠近我的星巴克。 但我不知道该怎么做。 现在我所能做的就是查看我当前的位置。
答案 0 :(得分:0)
使用ItemizedOverlay在android中显示多个标记,以了解逐项覆盖如何工作,以及它引用的链接和教程:
http://android-coding.blogspot.in/2011/06/using-itemizedoverlay-to-add-marker-on.html
https://github.com/commonsguy/cw-advandroid/tree/master/Maps/ILuvNooYawk/
答案 1 :(得分:0)
试试这个
public class MyMap extends MapActivity{
MapView mapView;
MapController mapController;
/* positon */
double latitude = Your latitude;
double longitude = Your longitude;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YourLayout);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapController = mapView.getController();
mapController.setZoom(8);
GeoPoint pointRabat = new GeoPoint(microDegres(latitude),
microDegres(longitude));
mapController.setCenter(pointRabat);
}
private int microDegres(double value) {
return (int) (value * 1000000);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
添加叠加
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub
GeoPoint pointRabat = new GeoPoint(microDegres(latitude),
microDegres(longitude));
OverlayItem overlayitem = new OverlayItem(point, "My Current Location", "My Current Location");
overlay.addOverlay(overlayitem);
mapOverlays.add(overlay);
}