lunes, 15 de mayo de 2017

Android Studio - Google Maps Api v2 - Añadiendo puntos





AndroidManifest.xml

(reemplazar paquete si es necesario !!! )


  <permission
        android:name="com.example.usuario.antutgooglemaps.permission.MAPS_RECEIVE"        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.usuario.antutgooglemaps.permission.MAPS_RECEIVE" />    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

MainActivity.java



import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
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.BitmapDescriptorFactory;
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);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }
    
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

       Antut(googleMap);
    }


    public void Antut (GoogleMap googleMap) {
        mMap = googleMap;

        final LatLng punto1 = new LatLng(40.4190531,-3.6936194);
        final LatLng punto2 = new LatLng(38.4190531,-3.6936194);
        mMap.addMarker(new MarkerOptions().position(punto1).title("Madrid-España").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
        mMap.addMarker(new MarkerOptions().position(punto2).title("Punto2").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));


    }



}


3 comentarios:

  1. hola buenos dias como estas, necesito realizar una app hay alguna forma que al maps se puedan agregar restripciones que alguna calle en especifico no se pueda transitar...

    ResponderBorrar
  2. ha y sobre todo excelente ejemplo... gracias...

    ResponderBorrar

Android Studio - Como crear un patron de desbloqueo

Librerias : https://github.com/aritraroy/PatternLockView                   https://github.com/pilgr/Paper activity_main.xml ...