Last active
August 29, 2015 14:24
-
-
Save William-ST/7ca95340790e4d415698 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.usuario.mapa; | |
| import android.location.Location; | |
| import android.os.Bundle; | |
| import android.support.v4.app.FragmentActivity; | |
| import android.view.Menu; | |
| import android.widget.Toast; | |
| import com.google.android.gms.location.LocationListener; | |
| import com.google.android.gms.maps.CameraUpdateFactory; | |
| import com.google.android.gms.maps.GoogleMap; | |
| import com.google.android.gms.maps.SupportMapFragment; | |
| import com.google.android.gms.maps.model.LatLng; | |
| import com.google.android.gms.maps.model.Marker; | |
| import com.google.android.gms.maps.model.MarkerOptions; | |
| public class MapsActivity extends FragmentActivity { | |
| private GoogleMap googleMap; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_maps); | |
| SupportMapFragment supportMapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); | |
| googleMap = supportMapFragment.getMap(); | |
| googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { | |
| @Override | |
| public void onMapClick(LatLng latLng) { | |
| MarkerOptions markerOptions = new MarkerOptions(); | |
| markerOptions.position(latLng); | |
| markerOptions.title(latLng.latitude + " : " + latLng.longitude); | |
| googleMap.clear(); | |
| googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); | |
| googleMap.addMarker(markerOptions); | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment