My target is to change marker title on button click. The problem is that I cannot get marker and set title of it in onCreate()
because it is initialized in onMapReady()
. I have the following code:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
updateMarkerTexts(marker, "ss", "gg");
}
});
return view;
}
and
@Override
public void onMapReady(final GoogleMap googleMap) {
mMap = googleMap;
enableMyLocation();
onMyLocationButtonClick();
final Marker marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(51.2001, 62.9187))
.title("Some title")
.snippet(getResources().getString(R.string.somestr))));
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService (Context.LAYOUT_INFLATER_SERVICE);
//some params
}
@Override
public View getInfoContents(Marker arg0) {
return null;
}
getInfoWindow(marker);
marker.showInfoWindow();
}