0% found this document useful (0 votes)
3 views1 page

HelloWorld Marker

This Java code defines a MapsActivity class that extends FragmentActivity and implements OnMapReadyCallback. It initializes a Google Map, adds a marker at the coordinates (10, 10) with the title 'Hello World', and moves the camera to that location with a zoom level of 10. The map is set up in the onCreate method using a SupportMapFragment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

HelloWorld Marker

This Java code defines a MapsActivity class that extends FragmentActivity and implements OnMapReadyCallback. It initializes a Google Map, adds a marker at the coordinates (10, 10) with the title 'Hello World', and moves the camera to that location with a zoom level of 10. The map is set up in the onCreate method using a SupportMapFragment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package com.example.

googlemap;

import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);

SupportMapFragment mapFragment = (SupportMapFragment)


getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng hello = new LatLng(10, 10);
mMap.addMarker(new MarkerOptions().position(hello).title("Hello World"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(hello, 10f));
}
}

You might also like