com.google.android.gms.maps.SupportMapFragment Java Examples

The following examples show how to use com.google.android.gms.maps.SupportMapFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShopLocationActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shop_location);
    Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT);
    FontManager.markAsIconContainer(findViewById(R.id.layout_shop_location), fontType);
    currentShopName = (TextView) findViewById(R.id.current_shop_name);
    currentShopName.setTypeface(fontType ,Typeface.BOLD);


    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(LocationServices.API)
                .build();
    }
    init();
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #2
Source File: NearByHospitalActivity.java    From BloodBank with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(getActivity());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkLocationPermission();
    }

    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.gMap);
    if (mapFragment != null) {
        mapFragment.getMapAsync(this);
    }
    else
    {
        Toast.makeText(getActivity(), "MapFragment is null, why?", Toast.LENGTH_LONG).show();
    }

}
 
Example #3
Source File: MapFragment.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
void initGoogleMap() {
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    mapFragment.getMapAsync(googleMap -> {
        //noinspection MissingPermission
        googleMap.setMyLocationEnabled(true);
        binding.mapSearchView.bindData(placeMapList, placeMap -> {
            LatLng latLng = new LatLng(placeMap.latitude, placeMap.longitude);
            int duration = getResources().getInteger(R.integer.map_camera_move_mills);
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng), duration, null);
            Marker marker = markers.get(placeMap.nameRes);
            if (marker != null) marker.showInfoWindow();
        });

        binding.loadingView.setVisibility(View.GONE);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        googleMap.setIndoorEnabled(true);
        googleMap.setBuildingsEnabled(true);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LAT_LNG_CENTER, DEFAULT_ZOOM));
        UiSettings mapUiSettings = googleMap.getUiSettings();
        mapUiSettings.setCompassEnabled(true);
        renderMarkers(placeMapList, googleMap);
    });
}
 
Example #4
Source File: SampleActivity.java    From clusterkraf with Apache License 2.0 6 votes vote down vote up
private void initMap() {
	if (map == null) {
		SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
		if (mapFragment != null) {
			map = mapFragment.getMap();
			if (map != null) {
				UiSettings uiSettings = map.getUiSettings();
				uiSettings.setAllGesturesEnabled(false);
				uiSettings.setScrollGesturesEnabled(true);
				uiSettings.setZoomGesturesEnabled(true);
				map.setOnCameraChangeListener(new OnCameraChangeListener() {
					@Override
					public void onCameraChange(CameraPosition arg0) {
						moveMapCameraToBoundsAndInitClusterkraf();
					}
				});
			}
		}
	} else {
		moveMapCameraToBoundsAndInitClusterkraf();
	}
}
 
Example #5
Source File: MainActivity.java    From effective_android_sample with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    // Googleマップ操作インスタンスを初期化
    if (mGoogleMap == null) {
        SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

        mGoogleMap = (fragment != null) ? fragment.getMap() : null;

        if (mGoogleMap != null) {
            mGoogleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); // ラベル付き航空写真モード
            mGoogleMap.setOnMarkerClickListener(mOnMarkerClickListener); // ピンをタップした場合の挙動を定義

            // 初期位置はビッグサイト東1ホール
            final LatLng bigSight = new LatLng(35.630665, 139.797055);
            mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(bigSight));
            mGoogleMap.moveCamera(CameraUpdateFactory.zoomTo(16));

            // ピンと区画を描画
            drawFields();
        }
    }
}
 
Example #6
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().hide();  // for hiding
    prefs = getSharedPreferences("MIB", Context.MODE_PRIVATE);
    editor = prefs.edit();

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        bPermissionGranted = checkLocationPermission();
    }


    mapFrag = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFrag.getMapAsync(this);
    setUpMapIfNeeded();
}
 
Example #7
Source File: MapFragment.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_map, null);
    getActivity().setTitle("Map");

    if (mapFragment == null) {
        mapFragment = SupportMapFragment.newInstance();
        mapFragment.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                LatLng latLng = new LatLng(latitude, longitude);
                googleMap.addMarker(new MarkerOptions().position(latLng)
                        .title("Singapore"));
                googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
                googleMap.setMinZoomPreference(15.0f);
                googleMap.setMaxZoomPreference(20.0f);
            }
        });
    }

    getChildFragmentManager().beginTransaction().replace(R.id.map, mapFragment).commit();

    return view;
}
 
Example #8
Source File: TrackLocationActivity.java    From Track-My-Location with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_track_location);

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.track_location);
    }

    ((App) getApplication()).getAppComponent().inject(this);
    initViewModel();
}
 
Example #9
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_where_am_i);

  mTextView = findViewById(R.id.myLocationText);

  // Obtain the SupportMapFragment and request the Google Map object.
  SupportMapFragment mapFragment =
    (SupportMapFragment)getSupportFragmentManager()
                          .findFragmentById(R.id.map);
  mapFragment.getMapAsync(this);

  GoogleApiAvailability availability = GoogleApiAvailability.getInstance();

  int result = availability.isGooglePlayServicesAvailable(this);
  if (result != ConnectionResult.SUCCESS) {
    if (!availability.isUserResolvableError(result)) {
      Toast.makeText(this, ERROR_MSG, Toast.LENGTH_LONG).show();
    }
  }

  mLocationRequest = new LocationRequest()
                       .setInterval(5000)
                       .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
 
Example #10
Source File: MapActivity.java    From homeassist with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(getString(R.string.menu_map));
    }

    setupIconGenerator();
    setupAdSense();

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #11
Source File: AbstractDetailActivity.java    From google-io-2014-compat with Apache License 2.0 6 votes vote down vote up
private void setupMap() {
    final GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    double lat = getIntent().getDoubleExtra("lat", 37.6329946);
    double lng = getIntent().getDoubleExtra("lng", -122.4938344);
    float zoom = getIntent().getFloatExtra("zoom", 15);

    LatLng position = new LatLng(lat, lng);
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(position, zoom));
    map.addMarker(new MarkerOptions().position(position));

    // We need the snapshot of the map to prepare the shader for the circular reveal.
    // So the map is visible on activity start and then once the snapshot is taken, quickly hidden.
    map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
        @Override
        public void onMapLoaded() {
            map.snapshot(new GoogleMap.SnapshotReadyCallback() {
                @Override
                public void onSnapshotReady(Bitmap bitmap) {
                    mapLoaded(bitmap);
                }
            });
        }
    });
}
 
Example #12
Source File: GeneralActivity.java    From GitJourney with Apache License 2.0 6 votes vote down vote up
@Override
public Fragment getItem(int position) {
    Log.v(TAG, "getItem, position = " + position);
    // getItem is called to instantiate the fragment for the given page.
    // Return a PlaceholderFragment (defined as a static inner class below).
    switch (position) {
        case 0:
            return FeedListFragment.newInstance();
        case 1:
            return RepositoriesListFragment.newInstance();
        case 2:
            return FollowingListFragment.newInstance();
        case 3:
            return FollowersListFragment.newInstance();
        case 4:
            return StarsListFragment.newInstance();
        case 5:
            LocationsReadyCallback callback = new LocationsReadyCallback(GeneralActivity.this);
            SupportMapFragment fragment = SupportMapFragment.newInstance();
            fragment.getMapAsync(callback);
            return fragment;
    }
    return PlaceholderFragment.newInstance(position + 1);
}
 
Example #13
Source File: LocationAlarmActivity.java    From LocationAware with Apache License 2.0 6 votes vote down vote up
private void initView() {
  locationPin = findViewById(R.id.location_pin);
  currentLocationBtn = findViewById(R.id.my_location_btn);
  checkPointsListBtn = findViewById(R.id.check_points_list_btn);
  View bottomSheet = findViewById(R.id.bottom_sheet);
  mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
  mBottomSheetBehavior.setHideable(true);
  mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);

  RecyclerView checkPointsList = findViewById(R.id.check_point_list_view);
  checkPointsList.setLayoutManager(new LinearLayoutManager(context));
  checkPointsList.setAdapter(checkPointsAdapter);
  autocompleteFragment = (PlaceAutocompleteFragment)
      getFragmentManager().findFragmentById(R.id.search_places_fragment);
  SupportMapFragment supportMapFragment =
      (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
  supportMapFragment.getMapAsync(this);
  bindEvents();
}
 
Example #14
Source File: LayersDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layers_demo);

    mSpinner = (Spinner) findViewById(R.id.layers_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.layers_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(this);

    mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic);
    mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location);
    mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings);
    mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor);

    SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #15
Source File: MapsActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    // Set up Google Maps
    SupportMapFragment mapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    // Set up the API client for Places API
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Places.GEO_DATA_API)
            .build();
    mGoogleApiClient.connect();

    // Set up Firebase
    Firebase.setAndroidContext(this);
    mFirebase = new Firebase(FIREBASE_URL);
    mFirebase.child(FIREBASE_ROOT_NODE).addChildEventListener(this);
}
 
Example #16
Source File: Sample2Activity.java    From MapViewPager with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_2);

    SupportMapFragment map = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setPageMargin(Utils.dp(this, 18));
    Utils.setMargins(viewPager, 0, 0, 0, Utils.getNavigationBarHeight(this));

    mvp = new MapViewPager.Builder(this)
            .mapFragment(map)
            .viewPager(viewPager)
            .position(2)
            .adapter(new Sample2Adapter(getSupportFragmentManager()))
            .callback(this)
            .build();
}
 
Example #17
Source File: MapsActivity.java    From LearningAppAndroid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
    }
    MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
        @Override
        public void ready(@NonNull MarketingCloudSdk marketingCloudSdk) {
            marketingCloudSdk.getAnalyticsManager().trackPageView("data://MapActivity", getResources().getString(R.string.app_name), null, null);
        }
    });

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #18
Source File: EstablishmentFragment.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(R.layout.establishment_fragment, container, false);
    } catch (InflateException e) {
        /* map is already there, just return view as it is */
    }
    ButterKnife.bind(this, view);

    ((MainActivity) getActivity()).setToolbarTitle(getContext().getString(R.string.establishments_title));

    toggleFabButton(false);
    mPresenter = new EstablishmentPresenterImpl(this, getContext(), getActivity());

    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(mPresenter);

    return view;
}
 
Example #19
Source File: ProgrammaticDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // It isn't possible to set a fragment's id programmatically so we set a tag instead and
    // search for it using that.
    SupportMapFragment mapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);

    // We only create a fragment if it doesn't already exist.
    if (mapFragment == null) {
        // To programmatically add the map, we first create a SupportMapFragment.
        mapFragment = SupportMapFragment.newInstance();

        // Then we add it using a FragmentTransaction.
        FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(android.R.id.content, mapFragment, MAP_FRAGMENT_TAG);
        fragmentTransaction.commit();
    }
    mapFragment.getMapAsync(this);
}
 
Example #20
Source File: NearbyLocationActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nearby_location);

    Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT);
    FontManager.markAsIconContainer(findViewById(R.id.layout_nearby_location), fontType);
    currentShopName = (TextView) findViewById(R.id.current_shop_name);
    currentShopName.setTypeface(fontType, Typeface.BOLD);

    polylines = new ArrayList<>();

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(LocationServices.API).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    init();
}
 
Example #21
Source File: MainActivity.java    From HRCarMarkerAnimation with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context=this;
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).build();
    createLocationRequest();
    markerCount = 0;


    mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(MainActivity.this);
}
 
Example #22
Source File: CompassMapFragment.java    From Compass with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #23
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);//Indicamos el contexto de la actividad actual
}
 
Example #24
Source File: BasicMapDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.basic_demo);

    SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #25
Source File: MainActivity.java    From roads-api-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);

    SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    mContext = new GeoApiContext().setApiKey(getString(R.string.google_maps_web_services_key));
}
 
Example #26
Source File: CameraClampingDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.camera_clamping_demo);

    mMap = null;
    resetMinMaxZoom();

    mCameraTextView = (TextView) findViewById(R.id.camera_text);

    SupportMapFragment mapFragment =
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
 
Example #27
Source File: PlaceOnAMapDialog.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getIntent().getExtras();
    this.title = args.getString("title", null);
    this.location = args.getParcelable("location");

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    setContentView(R.layout.dialog_place_on_a_map);

    TextView textViewTitle = (TextView) findViewById(R.id.dialog_title);
    if (this.title != null)
        textViewTitle.setText(this.title);
    else
        textViewTitle.setText(location.latitude + ", " + location.longitude);

    try {
        MapsInitializer.initialize(this);
    } catch (Exception e) {
        e.printStackTrace();
    }

    map = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    map.getUiSettings().setScrollGesturesEnabled(false);
    map.getUiSettings().setZoomGesturesEnabled(false);
    map.getUiSettings().setRotateGesturesEnabled(false);

    map.addMarker(new MarkerOptions()
            .position(location));

    CameraPosition newPosition = CameraPosition.fromLatLngZoom(location, 12.0f);
    map.moveCamera(CameraUpdateFactory.newCameraPosition(newPosition));
}
 
Example #28
Source File: LocationPickerDialog.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.location_picker_dialog);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    try {
        MapsInitializer.initialize(this);
    } catch (Exception e) {
        e.printStackTrace();
    }

    mMap = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    mMap.setMyLocationEnabled(true);

    if ( getIntent().getParcelableExtra("location") != null ) {
        final CameraPosition newPosition = CameraPosition.fromLatLngZoom((LatLng) getIntent().getParcelableExtra("location"), 15);

        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(newPosition));
            }
        }, 500);
    }

    findViewById(R.id.save).setOnClickListener(this);
    findViewById(R.id.cancel).setOnClickListener(this);
}
 
Example #29
Source File: MainActivity.java    From AutocompleteLocation with Apache License 2.0 5 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  SupportMapFragment mapFragment =
      (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
  mapFragment.getMapAsync(this);

  AutoCompleteLocation autoCompleteLocation =
      (AutoCompleteLocation) findViewById(R.id.autocomplete_location);
  autoCompleteLocation.setAutoCompleteTextListener(this);
}
 
Example #30
Source File: TileCoordinateDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tile_coordinate_demo);

    SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}