package de.tudarmstadt.informatik.hostage.ui2.fragment; import android.app.AlertDialog; import android.app.Dialog; import android.app.Fragment; import android.content.Context; import android.content.DialogInterface; import android.graphics.Color; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.gms.common.ConnectionResult; 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.CircleOptions; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import de.tudarmstadt.informatik.hostage.R; import static com.google.android.gms.common.GooglePlayServicesUtil.*; /** * Created by fabio on 10.02.14. */ public class ThreatMapFragment extends Fragment { private GoogleMap map = null; /** * if google play services aren't available an error notification will be displayed * * @return true if the google play services are available */ private boolean isGooglePlay() { int status = isGooglePlayServicesAvailable(getActivity()); boolean result = status == ConnectionResult.SUCCESS; if (result == false) { getErrorDialog(status, getActivity(), 10).show(); } return result; } private void loadMapFragment() { // Get a handle to the Map Fragment MapFragment mapFragment = (MapFragment) getFragmentManager() .findFragmentById(R.id.threatmapfragment); map = mapFragment.getMap(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //super.onCreateView(inflater, container, savedInstanceState); View rootView = inflater.inflate(R.layout.fragment_threatmap, container, false); if (isGooglePlay()) { loadMapFragment(); } if (map != null) { LatLng mapCenter = new LatLng(41.889, -87.622); map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 13)); map.addCircle(new CircleOptions().center(mapCenter).radius(200.0).fillColor(Color.RED).strokeColor( Color.MAGENTA)); } return rootView; } }