How to get all latlng of Route between two points in OSM - java

I'm working on app using open street map. I have draw route between two points. I want to get list of all latitudes and longitudes on the route polyline. If anyone knows please answer me.

**Here is the answer
just play with your polyline **
Polyline roadOverlay = RoadManager.buildRoadOverlay(road1);
roadOverlay.getPoints();

Related

Set marker on Polyline in google maps

I've tried to make possible choice on polyline in google maps. But I'm stuck.
For example: I have 10 points (with lines).
by using this part of code:
polylines = new PolylineOptions();
polylines.color(getResources().getColor(R.color.poly_line_color));
//add path points, set colour, etc. here
polyline = mMap.addPolyline(polylines);
polyline.setPoints(latLngs);
polyline.setClickable(true);
mMap.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
#Override
public void onPolylineClick(Polyline polyline) {
Logger.e("id : "+polyline.getPoints());
}
});
we can easy detect click on polyline. But - I can't detect current coordinates (latitude/longitude) for this click.
I tried method
"PolyUtil"
from another library - but this is work randomly and not correct. And really - look like it does not work. 10 clicks on map = 1 good point which is not on polyline or near this line.
Polyline polyline has only few methods and only one normal "getPoints()" but its returned all points.
Can anyone help me with this? I checked a lot of posts on SO but none helped me.
map.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
polyline.getPoints()
});
Try this function polyline.getPoints() in your code. This may help you. Thanks

Android - Is it possible to make a navigation on a .png?

I get a lat long from the backend and I want to use a PNG as a map, because this map is self made. So I want to transfer my lat long on this PNG and then draw at this position a point, but I couldn't figure it out how to do...
I couldn't find it here in another question. Maybe it's so easy that no one ever asked this.
I am new to Android and new to stackoverflow :)
EDIT because of comment: The image is a self made map. It was made with ESRI cityengine and Blender. Then I made a birdseye-screenshot of the map and this screenshot I want to use as my map.
EDIT 2: #MarkusKauppinen made a good comment! So I also want to convert the lat/long to x/y coordinates of the screen (like (How do android screen coordinates work?) ). But the lat/long of my backend don't relate to the lat/long of the Earth.
Even thought that this question has a downvote and probably no one will ever see it, I could figure it out how to solve my problem.
I used this Canvas Bitmap Method to draw the map on my screen. Then I converted the lat/long coordinates so that they fit on the Screen of the mobile phone with the help of this post: How do android screen coordinates work?
With the converted lat/long coordinates then I could draw a circle on the current position on the map. Now when the coordinates change the circle is moving like it should.

Pointing to a location in Google Maps in Android Studio

I am working on an app using android studio where cell data is saved in a database with it's corresponding location in latitude and longitude coordinates and users can access this data when there is no service to find a way to a good to better service. The data will be drawn to a google maps activity and color coordinated to represent the color but I also want to add an arrow the points from current location to the best cell service within a radius that I will set up.
Is it possible to draw an arrow to accomplish the task of pointing to a data point that is drawn? any info that points me in the right direction or the answer will help, thank you.
EDIT
The arrow design I have in mind points to the better signal but does not connect to the other location. I will figure out a more complex pointing device later in development so I am just looking for information on the possibility of a short pointer arrow that represents a "GO THAT WAY" response.
You can use Ground overlays , where you can set particular image at given latlong.
LatLng NEWARK = new LatLng(40.714086, -74.228697);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
.position(NEWARK, 8600f, 6500f);
map.addGroundOverlay(newarkMap);
for rotating the image you can look
https://stackoverflow.com/a/4332278/7386743
Are you talking about creating line between the two points ? Could you clearify more what do you exactly need ?
If it creating a line then you can use polyline
GoogleMap map;
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
.width(5)
.color(Color.RED));

Follow path given by Google Directions API at an average speed (Android)

I'm programming and app to allow parents remotely access their children position throughout a previously specified route.
To choose the origin and destination I use google maps API and then ask the Google directions API for the best route between those points and draw a polyline between those points.
My application - markers in initial position and destination, polyline drawn using route retrieved from Direction API
I could periodically send the child's position to the parent's device (latitude and longitude) and draw the polyline between those points but that's not my goal. My goal is to have the child's device send initial position and average speed for the first few meters of the path to the parent's device(no problem), and have the parent's device simulate the trajectory by following the previously drawn route ,received from directions api, at an average speed(problem).
Is this possible to draw a simulation following the previously drawn route? I already took a look at the google "snap to roads" but it's not exactly what I'm looking for...
Thanks so much in advance!

Drawing actual bus routes polyline Android

I'm doing an Android app which has a Google map in it. The main function of the app is to return a route between two locations, traveled by bus. However, the polyline returned by google direction api service for bus are just straight lines between bus stops, is there any way I can get the actual bus travelling routes? I have read stuffs and the only solution I found is to draw polyline snap to road, but it is not guaranteed that the bus actually travel using that road.
For example, if I request for a bus route between London Kings Cross station and London Waterloo station, and let's say this is my direction request URL:
maps.googleapis.com/maps/api/directions/json?origin=LondonKingsCross&destination=LondonWaterloo&mode=transit&transit_mode=bus&key=MY_API_KEY
Then I use the JSON result to draw my polyline, it would look something like this:
Zoomed in section of a polyline between two bus stops
However, the bus might actually travel like this:
Actual bus route
How/Where can I get the actual polyline(list of latlng points) that allows me to draw on my map?
Try the below link. Worked for me.
Draw Path using Json Response

Categories

Resources