Google Maps Android API - 如何自动选择标记?

时间:2015-05-13 04:10:09

标签: android google-maps

我正在向我的SupportMapFragment添加标记,如图所示。我希望自动显示标题,而不是要求用户点击标记。有办法吗?

    googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(
                    Double.parseDouble(getArguments().getString("lat")),
                    Double.parseDouble(getArguments().getString("lng"))
            ))
            .title(getArguments().getString("name")));

    try {
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(
                        Double.parseDouble(getArguments().getString("lat")),
                        Double.parseDouble(getArguments().getString("lng")))
                , new Float(15.0)
        ));
    } catch (Exception e) {
        //ignore
    }

1 个答案:

答案 0 :(得分:3)

感谢@JigneshJain,

Marker marker = googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(
                    Double.parseDouble(getArguments().getString("lat")),
                    Double.parseDouble(getArguments().getString("lng"))
            ))
            .title(getArguments().getString("name")));
marker.showInfoWindow();