import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class FindUsActivity extends android.support.v4.app.FragmentActivity {
GoogleMap find_us_map;
ImageButton btn_home;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_findus);
SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.activity_findus_map);
find_us_map = fragment.getMap();
find_us_map.setMyLocationEnabled(true);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title("Town Tour");
markerOptions.snippet("We are here");
LatLng latlng = new LatLng(40.4230, 98.7372);
find_us_map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 4));
find_us_map.animateCamera(CameraUpdateFactory.zoomTo(4), 2000, null);
markerOptions.position(latlng);
Marker m = find_us_map.addMarker(markerOptions);
btn_home = (ImageButton) findViewById(R.id.activity_findus_ibtn_home);
btn_home.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/activity_findus_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.example.towntour.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.towntour.android.maps.googlev2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.temp.android.maps.googlev2.permission.MAPS_RECEIVE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDp6PHK3NYNwS74cKGdfgdmX-xc4LuH_uM1mIo" />