S
S
Shohrukh Alimov2019-02-19 11:07:09
Android
Shohrukh Alimov, 2019-02-19 11:07:09

How can I get latitude and longitude from UserLocationView / user location?

I need to show in the application the current location of the user and the places around him. What do I need to get the user's LatLong (in Double)

@Override
    public void onObjectAdded(@NonNull UserLocationView userLocationView) {
        Double lat, lng;

        float width = (float) (mapView.getWidth() * 0.5);
        float height = (float) (mapView.getHeight() * 0.5);

        userLocationLayer.setAnchor(new PointF(width, height), new PointF(width, height));

        CompositeIcon pinIcon = userLocationView.getPin().useCompositeIcon();
        pinIcon.setIcon("pin", ImageProvider.fromResource(this, R.drawable.img_map_pointer_user),
                new IconStyle().setAnchor(new PointF(0.5f, 0.5f))
                        .setRotationType(RotationType.NO_ROTATION)
                        .setScale(5f));

        userLocationView.getAccuracyCircle().setFillColor(getColors(R.color.colorAccent));

        lat =.....
        lng = .....

        initCall(lat, lng);
    }

Something like in Google Maps
LatLng latLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2019-02-19
@freeExec

https://developer.android.com/reference/android/lo...
Choose the provider you need and subscribe to listen to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question