JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* This is an example of using Google Maps SDK in an Android application.
* The SDK simplifies adding maps and markers by providing pre-built tools.
*
* Steps to run:
* 1. Set up Android Studio and create a new Android project.
* 2. Add Google Maps SDK dependency in the build.gradle file.
* 3. Obtain a Google Maps API Key from the Google Cloud Console.
* 4. Insert the API Key into the AndroidManifest.xml.
* 5. Run the app on an Android device or emulator to see the map with a marker.
*
* Note: This code only works in an Android environment and requires an active internet connection.
*/
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// This loads the map
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run