title: android - Add a Marker to a Fragment Map from Activity
body: <p>I need to Add a Mark to a Android Google Map (Fragment) from a MainActivity</p>
  
  <p>This is my code; </p>
  
  <pre><code>class Map extends android.app.Fragment implements OnMapReadyCallback
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.activity_mapa, container,false);
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  
          MapFragment fragment = (MapFragment)getChildFragmentManager().findFragmentById(R.id.map);
          fragment.getMapAsync(this);
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap) {
          LatLng marker = new LatLng(19.33978502, -99.19086277);
          googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker, 15));
          googleMap.addMarker(new MarkerOptions().title("Marca de Prueba 1").position(marker));
      }
  }
  </code></pre>
  
  <p>And i want to add a mark from here:</p>
  
  <p>All this because i want to interact with my map from my main Activity where i have some buttons and EditText</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class MainActivityextends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener
  {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_side_bar);
      }
  
      FragmentManager fm = getFragmentManager();
      fm.beginTransaction().replace(R.id.content_frame, new Mapa()).commit();
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lylpH.png" rel="nofollow noreferrer">Here is how it looks, already has a mark, but insted of calling it from the map activity i need to set it from the MainActivity</a></p>