Created
March 26, 2014 05:39
-
-
Save enginebai/9777442 to your computer and use it in GitHub Desktop.
MapActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.os.Bundle; | |
import com.google.android.gms.maps.CameraUpdateFactory; | |
import com.google.android.gms.maps.GoogleMap; | |
import com.google.android.gms.maps.MapFragment; | |
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 MainActivity extends Activity | |
{ | |
static final LatLng GPS = new LatLng( 25.03880310058, 121.56798553466797 ); | |
private GoogleMap mMap; | |
@Override | |
protected void onCreate( Bundle savedInstanceState ) | |
{ | |
super.onCreate( savedInstanceState ); | |
setContentView( R.layout.activity_main ); | |
MapFragment mMapFragment = MapFragment.newInstance(); | |
android.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); | |
fragmentTransaction.add( R.id.map, mMapFragment ); | |
fragmentTransaction.commit(); | |
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); | |
Marker marker = mMap.addMarker( new MarkerOptions().position( GPS ) ); | |
mMap.moveCamera( CameraUpdateFactory.newLatLngZoom( GPS, 16 ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
layout