NumberFormat nf = NumberFormat.getInstance();double lat = 0;double lng = 0; try { lat = nf.parse(bienQuangCao.getBqc_latitude()).doubleValue(); lng = nf.parse(bienQuangCao.getBqc_longtidue()).doubleValue(); makerOptions.position(new LatLng(lat,lng)); mMap.addMarker(makerOptions); } catch (ParseException e) { e.printStackTrace(); }
Hello to coders, Previously we have taught you how you get current location using GPS/Network Provider . Then android has revealed FusedLocationProviderClient under GoogleApi . FusedLocationProviderClient is for interacting with the location using fused location provider. ( NOTE : To use this feature, GPS must be turned on your device. For manually ask the user to turn on GPS, please check next article ) So let’s get started for the tutorial for getting the current location. First, add a dependency for location by play services: implementation 'com.google.android.gms:play-services-location:15.0.1' Then define FusedLocationProviderClient: private FusedLocationProviderClient mFusedLocationClient; private TextView txtLocation; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. activity_main ); this.txtLocation = (TextView) findViewById(R.id. txtLocat...
Nhận xét
Đăng nhận xét