Guest User

Untitled

a guest
Dec 14th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 KB | None | 0 0
  1. public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
  2.  
  3. private GoogleMap mMap;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. setContentView(R.layout.activity_main);
  9. // Obtain the SupportMapFragment and get notified when the map is ready to be used.
  10.  
  11. int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
  12.  
  13. if(status == ConnectionResult.SUCCESS) {
  14.  
  15. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  16. .findFragmentById(R.id.map);
  17. mapFragment.getMapAsync(MapsActivity.this);
  18. }else{
  19. Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, (Activity)getApplicationContext(),10);
  20. dialog.show();
  21. }
  22. }
  23.  
  24. @Override
  25. public void onMapReady(GoogleMap googleMap) {
  26. mMap = googleMap;
  27.  
  28. mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
  29.  
  30. UiSettings uiSettings = mMap.getUiSettings();
  31. uiSettings.setZoomControlsEnabled(true);
  32.  
  33. // Add a marker in Sydney and move the camera
  34. LatLng burgerbanc = new LatLng(43.304640, -2.016711);
  35. mMap.addMarker(new MarkerOptions().position(burgerbanc).title("BurgerBanc Sociedad Limitada"));
  36. mMap.moveCamera(CameraUpdateFactory.newLatLng(burgerbanc));
  37. float zoomLevel=15;
  38.  
  39. mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(burgerbanc,zoomLevel));
  40. }
  41. }
  42.  
  43. <ImageView
  44. android:id="@+id/imageView4"
  45. android:layout_width="408dp"
  46. android:layout_height="0dp"
  47. android:layout_marginBottom="342dp"
  48. android:layout_marginTop="9dp"
  49. app:layout_constraintBottom_toTopOf="@+id/btnPedido"
  50. app:layout_constraintEnd_toEndOf="parent"
  51. app:layout_constraintStart_toStartOf="parent"
  52. app:layout_constraintTop_toTopOf="parent"
  53. app:srcCompat="@drawable/logo" android:contentDescription="@string/todo" />
  54.  
  55. <TextView
  56. android:id="@+id/textView7"
  57. android:layout_width="wrap_content"
  58. android:layout_height="30dp"
  59. android:layout_marginBottom="14dp"
  60. android:layout_marginStart="52dp"
  61. android:text="@string/email"
  62. android:textSize="20sp"
  63. android:textStyle="bold"
  64. app:layout_constraintBottom_toTopOf="@+id/textView"
  65. app:layout_constraintStart_toStartOf="@+id/imageView4" />
  66.  
  67. <TextView
  68. android:id="@+id/textView8"
  69. android:layout_width="wrap_content"
  70. android:layout_height="31dp"
  71. android:text="@string/direccionn"
  72. android:textSize="20sp"
  73. android:textStyle="bold"
  74. app:layout_constraintBottom_toTopOf="@+id/map"
  75. app:layout_constraintStart_toStartOf="@+id/textView" />
  76.  
  77. <TextView
  78. android:id="@+id/textView"
  79. android:layout_width="wrap_content"
  80. android:layout_height="30dp"
  81. android:layout_marginBottom="14dp"
  82. android:text="@string/tfono"
  83. android:textSize="20sp"
  84. android:textStyle="bold"
  85. app:layout_constraintBottom_toTopOf="@+id/textView8"
  86. app:layout_constraintStart_toStartOf="@+id/textView7" />
  87.  
  88. <fragment
  89. android:id="@+id/map"
  90. android:name="com.google.android.gms.maps.SupportMapFragment"
  91. android:layout_width="0dp"
  92. android:layout_height="211dp"
  93. android:layout_marginBottom="8dp"
  94. android:layout_marginEnd="15dp"
  95. android:layout_marginStart="15dp"
  96. app:layout_constraintBottom_toTopOf="@+id/btnPedido"
  97. app:layout_constraintEnd_toEndOf="parent"
  98. app:layout_constraintStart_toStartOf="parent"
  99. tools:context="com.example.urtzi.cebancburger.MapsActivity" />
  100.  
  101.  
  102. <Button
  103. android:id="@+id/btnPedido"
  104. android:layout_width="0dp"
  105. android:layout_height="wrap_content"
  106. android:layout_marginBottom="2dp"
  107. android:layout_marginEnd="42dp"
  108. android:layout_marginStart="42dp"
  109. android:text="@string/haz_ya_tu_pedido"
  110. app:layout_constraintBottom_toBottomOf="parent"
  111. app:layout_constraintEnd_toEndOf="parent"
  112. app:layout_constraintStart_toStartOf="parent"
  113. app:layout_constraintTop_toBottomOf="@+id/imageView4" />
  114.  
  115. <!--
  116. The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
  117. Google Maps Android API v2, but you must specify either coarse or fine
  118. location permissions for the 'MyLocation' functionality.
  119. -->
  120. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  121. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  122. <uses-permission android:name="android.permission.INTERNET" />
  123. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  124.  
  125. <application
  126. android:allowBackup="true"
  127. android:icon="@mipmap/ic_launcher"
  128. android:label="@string/app_name"
  129. android:roundIcon="@mipmap/ic_launcher_round"
  130. android:supportsRtl="true"
  131. android:theme="@style/AppTheme">
  132. <activity android:name=".MainActivity" />
  133. <activity android:name=".DatosActivity" />
  134. <activity android:name=".BurgerActivity" />
  135. <activity
  136. android:name=".SplashActivity"
  137. android:theme="@style/Theme.AppCompat.NoActionBar">
  138. <intent-filter>
  139. <action android:name="android.intent.action.MAIN" />
  140.  
  141. <category android:name="android.intent.category.LAUNCHER" />
  142. </intent-filter>
  143. </activity>
  144. <!--
  145. The API key for Google Maps-based APIs is defined as a string resource.
  146. (See the file "res/values/google_maps_api.xml").
  147. Note that the API key is linked to the encryption key used to sign the APK.
  148. You need a different API key for each encryption key, including the release key that is used to
  149. sign the APK for publishing.
  150. You can define the keys for the debug and release targets in src/debug/ and src/release/.
  151. -->
  152. <meta-data
  153. android:name="com.google.android.geo.API_KEY"
  154. android:value="@string/google_maps_key" />
  155.  
  156. <activity
  157. android:name=".MapsActivity"
  158. android:label="@string/title_activity_maps" />
  159. </application>
Add Comment
Please, Sign In to add comment