I have these two classes that call my map, and my activity that contains it, the issue is that I need to pass on the parent activity, the coordinates for the child activity, but I do not know how to do it, if I do a new method that go to the fragment, to fill the coordinates, do not assign them correctly, and another way I have no idea
MapViewFragment.java
public class MapViewFragment extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_fragment);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
LocalActivity.java
public class LocalActivity extends AppCompatActivity {
private Locales local;
@Override
protected void onCreate(Bundle savedInstanceState) {
final Context context = getContext();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_locales);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
int id;
id = getIntent().getIntExtra("id",0);
Servicio ser = new Servicio();
local = new Locales();
try {
local = ser.GetLocal(context, id);
} catch (JSONException e) {
e.printStackTrace();
}
toolbar.setTitle(local.getNombre());
}
}
Then I have my xml
content_locales.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
**<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="285dp"
android:id="@+id/map"
tools:context=".Fragment.MapViewFragment"
android:name="com.google.android.gms.maps.SupportMapFragment" />**
<Button
android:id="@+id/btnReservar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/solicitar_reserva" />
</LinearLayout>