Debian Codegraph @

templates/activities/GoogleMapsActivity/root/src/app_package/MapActivity.java.ftl

raw
1 package ${packageName};
2
3 import android.support.v4.app.FragmentActivity;
4 import android.os.Bundle;
5
6 import com.google.android.gms.maps.CameraUpdateFactory;
7 import com.google.android.gms.maps.GoogleMap;
8 import com.google.android.gms.maps.OnMapReadyCallback;
9 import com.google.android.gms.maps.SupportMapFragment;
10 import com.google.android.gms.maps.model.LatLng;
11 import com.google.android.gms.maps.model.MarkerOptions;
12
13 public class ${activityClass} extends FragmentActivity implements OnMapReadyCallback {
14
15 private GoogleMap mMap;
16
17 @Override
18 protected void onCreate(Bundle savedInstanceState) {
19 super.onCreate(savedInstanceState);
20 setContentView(R.layout.${layoutName});
21 // Obtain the SupportMapFragment and get notified when the map is ready to be used.
22 SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
23 .findFragmentById(R.id.map);
24 mapFragment.getMapAsync(this);
25 }
26
27
28 /**
29 * Manipulates the map once available.
30 * This callback is triggered when the map is ready to be used.
31 * This is where we can add markers or lines, add listeners or move the camera. In this case,
32 * we just add a marker near Sydney, Australia.
33 * If Google Play services is not installed on the device, the user will be prompted to install
34 * it inside the SupportMapFragment. This method will only be triggered once the user has
35 * installed Google Play services and returned to the app.
36 */
37 @Override
38 public void onMapReady(GoogleMap googleMap) {
39 mMap = googleMap;
40
41 // Add a marker in Sydney and move the camera
42 LatLng sydney = new LatLng(-34, 151);
43 mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
44 mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
45 }
46 }