Name: Shreyas Liladhar Lokhande Roll No: 41
Class: TYCM Batch: B
Subject: MAD
Practical No & Name: 31. Deploy map-based application. Part I
XML Code: Output:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="[Link]
android"
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mapFragment"
android:name="[Link]
.SupportMapFragment"
/>
</RelativeLayout>
Java Code :
package [Link].pr31;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity implements
OnMapReadyCallback {
private GoogleMap mMap;
private FusedLocationProviderClient fusedLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
fusedLocationClient =
[Link](this);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById([Link]);
if (mapFragment != null) [Link](this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap=googleMap;
showLocation();
}
@SuppressLint("MissingPermission")
private void showLocation() {
[Link]().addOnSuccessListener(this,
location -> {
if (location != null && mMap != null) {
LatLng userLocation = new LatLng([Link](),
[Link]());
[Link](new
MarkerOptions().position(userLocation).title("You are here"));
[Link]([Link](userLocation,
15));
}
});
}
}