0

我需要根据经纬度在地图中显示特定位置,并在该特定位置显示标记。但是,我已经显示了整个地图,但没有得到具体的位置。

public class MapActivity extends FragmentActivity {

GoogleMap googleMap;
MarkerOptions markerOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
       setContentView(R.layout.map);

    Intent intent = getIntent();
    String title = intent.getStringExtra("title");
    String lat = intent.getStringExtra("lat");
    String lon = intent.getStringExtra("long");
    double Lon = Double.parseDouble(lon);
    double Lat = Double.parseDouble(lat);

    SupportMapFragment supportMapFragment = (SupportMapFragment)
    getSupportFragmentManager().findFragmentById(R.id.map);

    googleMap = supportMapFragment.getMap();

    googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(Lat, Lon))
            .title(title));
      } }
4

1 回答 1

1

尝试如下:

  private Marker myMarker;
    myMarker=googleMap.addMarker(new MarkerOptions()
        .position(new LatLng(Lat, Lon))
        .title(title)
        .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
于 2013-02-21T13:39:03.300 回答