Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
- .findFragmentById(R.id.map);
- mapFragment.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(GoogleMap googleMap) {
- mMap = googleMap;
- mMap.getUiSettings().setScrollGesturesEnabled(false);
- address = prefs.getString(TAG_LOCATION, "");
- etLocation.setText(address);
- try {
- if (!prefs.getString(TAG_CUSTLATITUDE, "").equals("") && !prefs.getString(TAG_CUSTLONGITUDE, "").equals("")) {
- latitude = Double.parseDouble(prefs.getString(TAG_CUSTLATITUDE, ""));
- longitude = Double.parseDouble(prefs.getString(TAG_CUSTLONGITUDE, ""));
- address = prefs.getString(TAG_LOCATION, "");
- mMap.clear();
- mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
- mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
- Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), getResources().getIdentifier("ico_user_location", "drawable", getPackageName()));
- Bitmap resizedBitmap = Bitmap.createScaledBitmap(imageBitmap, imageBitmap.getWidth(), imageBitmap.getHeight(), false);
- llMap.setVisibility(View.VISIBLE);
- mMap.addMarker(new MarkerOptions()
- .position(new LatLng(latitude, longitude))
- .icon(BitmapDescriptorFactory.fromBitmap(resizedBitmap)));
- isLocationSet = true;
- }
- } catch (Exception e) {
- }
- }
- });
- implementation 'com.google.android.gms:play-services-maps:16.0.0'
- implementation 'com.google.android.gms:play-services-location:16.0.0'
- implementation 'com.google.android.gms:play-services-places:16.0.0'
Add Comment
Please, Sign In to add comment