Le Asignamos Un Nombre y Una Ubicación en El Proyecto
Le Asignamos Un Nombre y Una Ubicación en El Proyecto
Le Asignamos Un Nombre y Una Ubicación en El Proyecto
2
package com.example.appfase2;
import androidx.fragment.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.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapas);
// 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);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the
camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will
be prompted to install
* it inside the SupportMapFragment. This method will only be triggered
once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// muestra ubicacion de domicilio
LatLng actu = new LatLng(-16.329051,-71.537910);
mMap.addMarker(new MarkerOptions().position(actu).title("Marcador en
un domicilio"));
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(actu,12));
}
}
2
Código del google_maps_api.xml
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at
the end:
https://console.developers.google.com/flows/enableapi?
apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=D5:99:EF:47:FC:D5:31
:CC:84:22:11:8B:C1:42:D3:AA:E4:DC:24:8D%3Bcom.example.mapasgo
You can also add your credentials to an existing key, using these values:
Package name:
com.example.mapasgo
Once you have your key (it starts with "AIza"), replace the
"google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">AIzaSyDxhvpHQYfzlzogEp3ye1lgUsXyYrg1dAo</string>
</resources>
2
Clave de API Generada
To do this, you can either add your release key credentials to your
existing
key, or create a new key.
Note that this file specifies the API key for the release build target.
If you have previously set up a key for the debug target with the debug
signing certificate,
you will also need to set up a key for your release certificate.
https://developers.google.com/maps/documentation/android/signup
Once you have your key (it starts with "AIza"), replace the
"google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">AIzaSyBlNAGXhjsuPK2UnPMIlII6t3VkzdG4a44</string>
</resources>
2
Vistas del emulador:
package com.example.softcomfort.ui.share;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.softcomfort.R;
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;
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng softComfortArequipa = new LatLng(-16.422935, -71.527245);
googleMap.addMarker(new
MarkerOptions().position(softComfortArequipa).title("Arequipa"));
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(softComfortArequipa,
16));
}
};
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_share, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle
savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SupportMapFragment mapFragment =
(SupportMapFragment)
getChildFragmentManager().findFragmentById(R.id.map);
if (mapFragment != null) {
mapFragment.getMapAsync(callback);
}
}
}
2
google_maps_api.xml
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at
the end:
https://console.developers.google.com/flows/enableapi?
apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=E1:C6:18:77:8A:CD:EA
:01:DA:06:B6:C1:6D:87:69:73:12:E0:41:C9%3Bcom.example.softcomfort
You can also add your credentials to an existing key, using these values:
Package name:
com.example.softcomfort
Once you have your key (it starts with "AIza"), replace the
"google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">AIzaSyCRkzsmgQHQmEvVPJiGWG8-zKcVoCYCw4Y</string>
</resources>
fragment_share.xml
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayoutShare"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:background="@drawable/border"
app:layout_constraintBottom_toTopOf="@+id/textViewSubtittleShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
app:layout_constraintBottom_toTopOf="@+id/textViewSubtittleShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<TextView
android:id="@+id/textViewSubtittleShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
2
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="Sede Arequipa:"
android:textColor="@color/brown"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@+id/textViewCentralShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayoutShare" />
<TextView
android:id="@+id/textViewCentralShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/catamaran_medium"
android:text="Central:"
android:textColor="@color/background"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/textViewCellShare"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewSubtittleShare"
/>
<TextView
android:id="@+id/textViewCellShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/catamaran_medium"
android:text="Celular:"
android:textColor="@color/background"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/textViewWhatsappShare"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewCentralShare"
/>
<TextView
android:id="@+id/textViewWhatsappShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/catamaran_medium"
android:text="Whatsapp:"
android:textColor="@color/background"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/textViewEmailShare"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewCellShare" />
<TextView
android:id="@+id/textViewEmailShare"
2
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/catamaran_medium"
android:text="Correo:"
android:textColor="@color/background"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/textView11"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewWhatsappShare"
/>
<TextView
android:id="@+id/textViewPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="(054) - 429505"
android:textColor="@color/brown"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/textViewCentralShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textViewCentralShare"
app:layout_constraintTop_toTopOf="@+id/textViewCentralShare" />
<TextView
android:id="@+id/textViewCell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="979344135 - 974206448"
android:textColor="@color/brown"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/textViewCellShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textViewCellShare"
app:layout_constraintTop_toTopOf="@+id/textViewCellShare" />
<TextView
android:id="@+id/textViewWhatsappCell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="979344135 - 974206448"
android:textColor="@color/brown"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/textViewWhatsappShare"
app:layout_constraintEnd_toEndOf="parent"
2
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textViewWhatsappShare"
app:layout_constraintTop_toTopOf="@+id/textViewWhatsappShare" />
<TextView
android:id="@+id/textViewEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="softcomfort@hotmail.com"
android:textColor="@color/brown"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/textViewEmailShare"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textViewEmailShare"
app:layout_constraintTop_toTopOf="@+id/textViewEmailShare" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:fontFamily="@font/catamaran_medium"
android:text="Dirección:"
android:textColor="@color/background"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewEmailShare" />
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/catamaran_bold"
android:text="Urb. Quinta Tristan Z1 - 16 JLBR"
android:textColor="@color/brown"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/textView11"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textView11"
app:layout_constraintTop_toTopOf="@+id/textView11" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
2
CUESTIONARIO
1. ¿Cómo se realiza la incorporación del servicio de Google Maps?