标记';没有显示:谷歌地图Android
在我的项目中,我以编程方式在片段上加载地图。但是,在此地图上添加标记不起作用。没有显示错误,但标记也不在地图上 我正在跟踪,所以我不知道为什么它不起作用。 (标记器和摄像机的Lat和Lng相同) 我的片段代码标记';没有显示:谷歌地图Android,android,google-maps,Android,Google Maps,在我的项目中,我以编程方式在片段上加载地图。但是,在此地图上添加标记不起作用。没有显示错误,但标记也不在地图上 我正在跟踪,所以我不知道为什么它不起作用。 (标记器和摄像机的Lat和Lng相同) 我的片段代码 public class MainMapFragment extends Fragment implements OnMapReadyCallback { SupportMapFragment mMapFragment; static final LatLng LIBRARY = new
public class MainMapFragment extends Fragment implements OnMapReadyCallback {
SupportMapFragment mMapFragment;
static final LatLng LIBRARY = new LatLng(Lat, Lng);
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
return inflater.inflate(R.layout.main_map_layout,container,false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
//Set the initial stage of the map
//It is set on code (not on the xml) because the map is created programmatically
GoogleMapOptions options = new GoogleMapOptions();
CameraPosition ufv_position = new CameraPosition.Builder()
.target(new LatLng(Lat,Lng))
.zoom(15)
.tilt(0)
.bearing(40)
.build();
options.mapType(GoogleMap.MAP_TYPE_NORMAL)
.compassEnabled(false)
.rotateGesturesEnabled(false)
.tiltGesturesEnabled(false)
.camera(ufv_position);
//Load the map with the given options
mMapFragment = SupportMapFragment.newInstance(options);
FragmentTransaction fragmentTransaction =
getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.map, mMapFragment);
fragmentTransaction.commit();
}
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.addMarker(new MarkerOptions()
.position(LIBRARY)
.title("Library")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.book)));
}
}添加
mmapfracent.getmapsync(此)
因此您的onMapReady方法被调用addmmapfracent.getmapsync(this)
因此调用了onMapReady方法我只是隐藏了问题的坐标。但是我把它放在我放相机的地方。(这是一个有效的坐标)我刚刚隐藏了问题的坐标。但是我把它放在我放相机的地方。(这是一个有效的坐标)