Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
- private GoogleMap mMap;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- // Obtain the SupportMapFragment and get notified when the map is ready to be used.
- int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
- if(status == ConnectionResult.SUCCESS) {
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
- .findFragmentById(R.id.map);
- mapFragment.getMapAsync(MapsActivity.this);
- }else{
- Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, (Activity)getApplicationContext(),10);
- dialog.show();
- }
- }
- @Override
- public void onMapReady(GoogleMap googleMap) {
- mMap = googleMap;
- mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
- UiSettings uiSettings = mMap.getUiSettings();
- uiSettings.setZoomControlsEnabled(true);
- // Add a marker in Sydney and move the camera
- LatLng burgerbanc = new LatLng(43.304640, -2.016711);
- mMap.addMarker(new MarkerOptions().position(burgerbanc).title("BurgerBanc Sociedad Limitada"));
- mMap.moveCamera(CameraUpdateFactory.newLatLng(burgerbanc));
- float zoomLevel=15;
- mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(burgerbanc,zoomLevel));
- }
- }
- <ImageView
- android:id="@+id/imageView4"
- android:layout_width="408dp"
- android:layout_height="0dp"
- android:layout_marginBottom="342dp"
- android:layout_marginTop="9dp"
- app:layout_constraintBottom_toTopOf="@+id/btnPedido"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:srcCompat="@drawable/logo" android:contentDescription="@string/todo" />
- <TextView
- android:id="@+id/textView7"
- android:layout_width="wrap_content"
- android:layout_height="30dp"
- android:layout_marginBottom="14dp"
- android:layout_marginStart="52dp"
- android:text="@string/email"
- android:textSize="20sp"
- android:textStyle="bold"
- app:layout_constraintBottom_toTopOf="@+id/textView"
- app:layout_constraintStart_toStartOf="@+id/imageView4" />
- <TextView
- android:id="@+id/textView8"
- android:layout_width="wrap_content"
- android:layout_height="31dp"
- android:text="@string/direccionn"
- android:textSize="20sp"
- android:textStyle="bold"
- app:layout_constraintBottom_toTopOf="@+id/map"
- app:layout_constraintStart_toStartOf="@+id/textView" />
- <TextView
- android:id="@+id/textView"
- android:layout_width="wrap_content"
- android:layout_height="30dp"
- android:layout_marginBottom="14dp"
- android:text="@string/tfono"
- android:textSize="20sp"
- android:textStyle="bold"
- app:layout_constraintBottom_toTopOf="@+id/textView8"
- app:layout_constraintStart_toStartOf="@+id/textView7" />
- <fragment
- android:id="@+id/map"
- android:name="com.google.android.gms.maps.SupportMapFragment"
- android:layout_width="0dp"
- android:layout_height="211dp"
- android:layout_marginBottom="8dp"
- android:layout_marginEnd="15dp"
- android:layout_marginStart="15dp"
- app:layout_constraintBottom_toTopOf="@+id/btnPedido"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- tools:context="com.example.urtzi.cebancburger.MapsActivity" />
- <Button
- android:id="@+id/btnPedido"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginBottom="2dp"
- android:layout_marginEnd="42dp"
- android:layout_marginStart="42dp"
- android:text="@string/haz_ya_tu_pedido"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/imageView4" />
- <!--
- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
- Google Maps Android API v2, but you must specify either coarse or fine
- location permissions for the 'MyLocation' functionality.
- -->
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true"
- android:theme="@style/AppTheme">
- <activity android:name=".MainActivity" />
- <activity android:name=".DatosActivity" />
- <activity android:name=".BurgerActivity" />
- <activity
- android:name=".SplashActivity"
- android:theme="@style/Theme.AppCompat.NoActionBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <!--
- The API key for Google Maps-based APIs is defined as a string resource.
- (See the file "res/values/google_maps_api.xml").
- Note that the API key is linked to the encryption key used to sign the APK.
- You need a different API key for each encryption key, including the release key that is used to
- sign the APK for publishing.
- You can define the keys for the debug and release targets in src/debug/ and src/release/.
- -->
- <meta-data
- android:name="com.google.android.geo.API_KEY"
- android:value="@string/google_maps_key" />
- <activity
- android:name=".MapsActivity"
- android:label="@string/title_activity_maps" />
- </application>
Add Comment
Please, Sign In to add comment