buat peta.java ingat letakny file sesuaikan dengan letak file yang sudah diatur di google developer mu
package com.hasta.peta; import com.hasta.peta.R; import android.os.Bundle; import android.support.v4.app.FragmentActivity; public class peta extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.peta_layout); //Try to obtain the map from the SupportMapFragment. getSupportFragmentManager().findFragmentById(R.id.map); }}
buat layout di res>layout dengan nama peta_layout.xml
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.SupportMapFragment"/>
lalu tambahkan pada manifest ny
<uses-permission android:name="br.com.lineapp.tofind.permission.MAPS_RECEIVE"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <!-- The following two permissions are not required to use Google Maps Android API v2, but are recommended nanti dipakai untuk deteksi lokasi --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
dan tambahkan juga pada manifest namun letakan pada tag application
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="Isi_denganApiKeyMU" />
jadinya:
0 komentar:
Post a Comment