Skip to content

Instantly share code, notes, and snippets.

@theSociableme
Created March 4, 2013 21:08
Show Gist options
  • Save theSociableme/5085684 to your computer and use it in GitHub Desktop.
Save theSociableme/5085684 to your computer and use it in GitHub Desktop.
GoogleMapFragment
/**
* Created with IntelliJ IDEA.
*
* @author Mark Wagner
* Date: 2/27/13
* Time: 2:47 PM
*/
public class GoogleMapFragment extends Fragment {
private SupportMapFragment mMapFragment;
private GoogleMap mMap;
private final LatLng PLANET_HOLLYWOOD = new LatLng(36.1100, -115.1710);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GoogleMapOptions mapOptions = new GoogleMapOptions();
mapOptions.compassEnabled(true).camera(new CameraPosition(PLANET_HOLLYWOOD, 13, 0f, 0f));
mMapFragment = SupportMapFragment.newInstance(mapOptions);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = inflater.inflate(R.layout.google_map,
container, false);
getChildFragmentManager().beginTransaction().add(R.id.map_holder, mMapFragment).commit();
return view;
}
@Override
public void onResume() {
super.onResume();
mMap = mMapFragment.getMap();
if(mMap != null){
mMap.addMarker(new MarkerOptions().position(PLANET_HOLLYWOOD).title("Planet Hollywood"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment