I have the Latitude and Longitude stored in the database, but how can i show it in a Map View instead of opening the coordinates every time on a browser.
Can i display it inside the Native Android App and not redirect everytime to Google Maps ?
I have the Latitude and Longitude stored in the database, but how can i show it in a Map View instead of opening the coordinates every time on a browser.
Can i display it inside the Native Android App and not redirect everytime to Google Maps ?
You Can Show Maps In Your Map By Using Map Fragment Or Map Activity first add fragment in xml:
<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="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
second Implement OnMapReadyCallback and override onMapReady function
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// 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);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney 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));
}
}
the steps described in android developer site here
Note That To Use Display Google Maps In Your App You Need API KEY You Can generate Your Key In Google Developer Console and this is link for that
Try this code , after you get the lat long from the firestore.
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latlong);
markerOptions.title(latlong.latitude + " : " + latlong.longitude);
googleMap.clear();
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latlong));
googleMap.addMarker(markerOptions);