I have a class with map, and took coordinates and title
, from Firebase
in String
format, then put them into double
, but can't place them to new LatLng
? I understand, that problem is that googleMap = null
, but re-tried all the ways to solve it. In this version of code, nullexception
is disapearing, but marker
is empty. Help please. It the last problem of my app..
public class Map_activity extends FragmentActivity implements OnMapReadyCallback{
GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_activity);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
String value = getIntent().getExtras().getString("qwerty");
String xlat = getIntent().getExtras().getString("lat");
String xlon = getIntent().getExtras().getString("lon");
xlat.split(",");
xlon.split(",");
String [] latlong = {xlat, xlon};
double latitude = Double.parseDouble(latlong[0]);
double longitude = Double.parseDouble(latlong[1]);
if (googleMap != null){
LatLng location = new LatLng(latitude, longitude);
googleMap.addMarker(new MarkerOptions().position(location).title(value));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(location));}
}
public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
}
}