Android MapFragment - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MapFragment class.

This code example shows how to use the following methods:getActivity, getMap
 
	public void initMapIfNeeded() { 
		if (_googleMap == null) {
			// 2 cases now. It's either google play service is unavailable or not really initialized 
 
			_googleMap = _mapFragment.getMap();
			if (_googleMap == null) {
				// google play service is not available on user's device, we simply return. 
				// activity will call this method in onResume() 
				return; 
				// then MapFragment will show a label and a button directing user to download google play service 
			} 
 
			try { 
				MapsInitializer.initialize(_mapFragment.getActivity());
			} catch (GooglePlayServicesNotAvailableException e) {
				Log.e(GoogleMapManager.class.getSimpleName(), e.toString());
				return; 
			} 
 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:onCreateView, getActivity
	 
	 
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
	mOriginalContentView = super.onCreateView(inflater, parent, savedInstanceState);
	 
	mTouchView = new TouchableWrapper(getActivity());
	mTouchView.addView(mOriginalContentView);
	 
	return mTouchView;
	} 
	 
	@Override 
	public View getView() {
	   return mOriginalContentView;
	} 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:onPause, getActivity
    } 
  } 
 
  @Override 
  public void onPause() { 
    super.onPause(); 
    if (observer != null) {
      getActivity().getContentResolver().unregisterContentObserver(observer);
      observer = null;
    } 
  } 
 
  private void updateCamera(LatLng latLang) {
    // Construct a CameraPosition focusing on Mountain View and animate the camera to that position. 
    CameraPosition cameraPosition = new CameraPosition.Builder().target(latLang) // Sets the center of the map to Mountain View
                                                                .zoom(17)
                                                                // Sets the zoom 
                                                                .build();
    // Creates a CameraPosition from the builder 
    getMap().animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
import com.google.android.gms.maps.model.CameraPosition; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.MarkerOptions; 
import com.tfick.android.R; 
 
public class PoiFragment extends MapFragment {
    /*object of google map*/ 
    public GoogleMap mGoogleMap;
    /* summy location*/ 
    private static final LatLng SYDNEY = new LatLng(23.03, 72.62);
 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        return super.onCreateView(inflater, container, savedInstanceState);
    } 
 
    @Override 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
	public void setCaption(String caption) { 
		this.caption = caption; 
	} 
 
	public MyMapFragment(){} 
	 
	 
	/*@Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) { 
        View view = inflater.inflate(R.layout.activity_maps, container); 
        MapView mapView = (MapView)view.findViewById(R.id.map); 
        return view; 
        } 
	public void plot(){ 
		  Log.w("TEST MAP:","4#############"); 
		 // android.app.FragmentManager fm = getFragmentManager(); 
		  Log.w("TEST MAP:","4111111#############:::"+fm); 
		  MapFragment mF = ((MapFragment)fm.findFragmentById(R.id.map)); 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
import android.view.Menu; 
import android.view.MenuInflater; 
import android.view.View; 
import android.view.ViewGroup; 
 
public class FindFoodFragment extends MapFragment {
 
    /*public View onCreateView(LayoutInflater inflater, ViewGroup container, 
                             Bundle savedInstanceState) { 
    	 
    	 
        // Inflate the layout for this fragment 
        return inflater.inflate(R.layout.activity_main, container, false); 
    }*/ 
     
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	this.setHasOptionsMenu(true);
    } 
     
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMap
	String provider = LocationManager.NETWORK_PROVIDER;
 
	@AfterViews 
	void init() { 
		manager.requestLocationUpdates(provider, 10000, 50, this);
		map = mapFragment.getMap();
		map.getUiSettings().setMyLocationButtonEnabled(true);
	} 
 
	@UiThread 
	void makeText(String text) {
		Toast.makeText(this, text, Toast.LENGTH_LONG).show();
	} 
 
	@Click 
	void getLocation() { 
		Location l = manager.getLastKnownLocation(provider);
		if (l != null) {
			MarkerOptions marker = new MarkerOptions();
			LatLng ll = new LatLng(l.getLatitude(), l.getLongitude());
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMap
	public void moveTo(SupportMarker marker){
		mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(marker.getMarker().getPosition()));
	} 
	 
	public static SupportGoogleMap newInstance(Context context, MapFragment mapFragment) throws NoPlayServicesFoundException{
		SupportGoogleMap map = new SupportGoogleMap(context, mapFragment.getMap());
		return map;
	} 
	 
	public static SupportGoogleMap newInstance(Context context, SupportMapFragment mapFragment) throws NoPlayServicesFoundException{
		SupportGoogleMap map = new SupportGoogleMap(context, mapFragment.getMap());
		return map;
	} 
	 
	public static SupportGoogleMap newInstance(Context context, GoogleMap map) throws NoPlayServicesFoundException{
		SupportGoogleMap mapInstance = new SupportGoogleMap(context, map);
		return mapInstance;
	} 
	 
	/** 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMap
	@Override 
	protected void onStart() { 
		// TODO Auto-generated method stub 
		super.onStart(); 
		mMapFragment = ((MapFragment) getFragmentManager().findFragmentByTag("Mapa"));
		mMap = mMapFragment.getMap();
		 
		 
		mMap.setIndoorEnabled(true);
		mMap.setMyLocationEnabled(true);
		 
		 
		mMap.setTrafficEnabled(true);
		 
		String[] cordenadas = Cordenadas.split(",");
		 
		CameraUpdate camUpd1 =
			    CameraUpdateFactory.newLatLngZoom(new LatLng(Double.parseDouble(cordenadas[0]), Double.parseDouble(cordenadas[1])),mMap.getMaxZoomLevel() -2);
			  
		mMap.moveCamera(camUpd1);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	GeoPoint myGeoPoint;
	LatLng latlong;
 
 
	public Mapfragment() { 
		this.fragment = new MapFragment();
	} 
 
	public static void addMarkers(JSONObject array) {
		if (array != null) {
			Iterator iter = array.keys();
			while (iter.hasNext()) {
				try { 
					JSONObject obj = (JSONObject) array.get((String)iter.next());
					Log.d("ADDMARKERS", "lat = " + obj.getDouble("lat") + ", long = " + obj.getDouble("long"));
 
 
					markers.add(map.addMarker(new MarkerOptions().position(new LatLng(obj.getDouble("lat"), obj.getDouble("long"))).title(obj.getString("name"))));
 
				} catch (JSONException e) {
3
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android MapFragment Questions & Answers:

Other Android MapFragment Examples

21:	    super.onCreate(savedInstanceState);
22:	    setContentView(R.layout.activity_main);
23:	    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
24:	        .getMap();
25:	    Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)

Read More

23:		private void initilizeMap() {
24:			if (googleMap == null) {
25:				googleMap = ((MapFragment) getFragmentManager().findFragmentById(
26:						R.id.map)).getMap();
27:

Read More

See Code Examples for Android MapFragment Methods: