Guest User

Untitled

a guest
Dec 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  2. .findFragmentById(R.id.map);
  3. mapFragment.getMapAsync(new OnMapReadyCallback() {
  4. @Override
  5. public void onMapReady(GoogleMap googleMap) {
  6. mMap = googleMap;
  7. mMap.getUiSettings().setScrollGesturesEnabled(false);
  8. address = prefs.getString(TAG_LOCATION, "");
  9. etLocation.setText(address);
  10. try {
  11. if (!prefs.getString(TAG_CUSTLATITUDE, "").equals("") && !prefs.getString(TAG_CUSTLONGITUDE, "").equals("")) {
  12. latitude = Double.parseDouble(prefs.getString(TAG_CUSTLATITUDE, ""));
  13. longitude = Double.parseDouble(prefs.getString(TAG_CUSTLONGITUDE, ""));
  14. address = prefs.getString(TAG_LOCATION, "");
  15. mMap.clear();
  16. mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
  17. mMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
  18.  
  19. Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), getResources().getIdentifier("ico_user_location", "drawable", getPackageName()));
  20. Bitmap resizedBitmap = Bitmap.createScaledBitmap(imageBitmap, imageBitmap.getWidth(), imageBitmap.getHeight(), false);
  21.  
  22. llMap.setVisibility(View.VISIBLE);
  23.  
  24. mMap.addMarker(new MarkerOptions()
  25. .position(new LatLng(latitude, longitude))
  26. .icon(BitmapDescriptorFactory.fromBitmap(resizedBitmap)));
  27.  
  28.  
  29. isLocationSet = true;
  30. }
  31. } catch (Exception e) {
  32. }
  33. }
  34. });
  35.  
  36.  
  37. implementation 'com.google.android.gms:play-services-maps:16.0.0'
  38. implementation 'com.google.android.gms:play-services-location:16.0.0'
  39. implementation 'com.google.android.gms:play-services-places:16.0.0'
Add Comment
Please, Sign In to add comment