Description: In this article about uber driver login, the author is going to do the marker dragger feature. The user will be able to pin point any desired location on the map. The driver will get the location and come to that point.
Welcome to my another article on Android app development, this will be the part 17 of my series on uber clone app using Android studio, in this article I am going to use the marker dragger feature, when they use that move to screen feature, the marker will be moved.
The location of the user will be updated, if the user will be able to select any place he wants where the car will come, we will achieve that, before that I want to show you that I already have a drawable one, the user will be able to drag the marker from one place to another when he moves the map.
I already have this at the center of the signal, for that I have used the layout center horizontal and centers vertical, after that what you can do is inside your own location you can change method, after you set the current marker, you need to use the mMap.set on camera idle listener.
Inside our own camera idle methods, the first of all we want to get is the latitude and longitude, for that we can say that long, we need to find the laptop of the center of the camera, we can say mmap.getcameraposition.target, first of all let me open the layout which we have.
We have this layout, this is the select pickup location, let’s try to change it to hint, let’s try to change the text to hint, we need to check what the ID is, it is button five, if we already have button five, it’s b5 destination button, we can check if b5.to string.equals.
Current marker is not equal, it is null, we have checked if the texture of the button is empty, the current marker is not equal to null, we need to remove the current marker, we can say current marker.remove, then we need to add the marker.
For that you can say current marker equals to mmap.add marker. before that we can use the marker options m2 equals to new marker options, then we can say m2.title use current location, we can say m2.position, instead of this position, we can say center here.
Instead of the add marker method, we can pass, after that we need to start, let’s set it to our current location, we can say current marker.get position, finally we need to set the string address, we can say b4.set text, inside that we can say get string address.
Inside that we can say current marker.get position.latitude.current marker.get position.longitude, here we have this get string address method, it receives the latitude and longitude, it converts it into the physical address, it’s a beautiful part.
We can say i1.set visibility.view.gone, let’s try to run our application, let’s see if it works, let me first of all connect my phone, now my phone is connected, let’s open the side sync app, my phone is now already connected, let’s now try to run our application, let’s see if the application works.
Our application is now running, I have this location, the address is shown, if I want to drag this, you can see that the address is now updated, let’s try to change that, let’s try to have this, if I click on that destination location and if I click on Meherban colony, you can see that we have this Meherban colony.
In my next article, we are going to use the Google Direction API to display the direction between our pickup location and the destination location, after that we will find the distance between them in kilometers, after that we will also find how much time it will take to reach from the pickup location to the destination location, we will calculate the fair, the fair will be shown to the rider.