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
Related
I would like to ask is it possible to draw route between two location on Map without using Direction API?
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));
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!
I am making an application where one person can watch all the other users of the app driving on the streets. I am using google maps and I am animating markers on the map, as the location of the users is changed in real time using socket.io.
The problem is that most of the phones have not so accurate gps, and the pins are moved all across the map, not only on the streets, the sometimes jump on the grass, water, they are rotated in the wrong direction, etc... Is it somehow possible to move the markers on the street only?
I guess this can be done using google's direction API. You can request google direction api for the point you have to another point on the road. Google's response first point can be taken as on the nearest road point. I had look on the similar solutions people done on the web.
Have a look on this.
I want to make an Android App, with a real map and a overlay for the map, where sprites are drawn (can be dots or small images).
This is a rather hard question, so I have made a sketch of a map of a small city, where only roads and streets can be seen. That might look something like this on the device:
Imagine the red dots to be bots, and they want to get to the yellow dot, assuming they know the position.
What Android Map API should I use to be able to:
Draw custom sprites on a given location on the map (geo-coordinates rather than screen coordinates).
Generate valid paths from the streets and roads on the map, which the dots can move on (black lines).
Use pathfinding to calculate the shortest routes, e.g. from red dot to yellow dot.
Must be able to draw more than 10 sprites on the map.
(the map doesn't have to support 3d views or street views. Plain old top-down view is just fine)
If no map API exists that does not meet these requirements, what are some other solutions?
I'm really excited about this project, but I'm having a lot of trouble getting started with it, so any help or guidance will be much appreciated.
EDIT:
It seems that there is no answer to my question. I will leave this open and report back with my own solution.
Google Maps Android API v2 and Marker class.
All valid paths? You probably should not need it if you use Android API v2 with real map drawn for you, but you can also try to use Google Directions API.
Google Directions API.
No API exist that can handle more than 10 objects. You probably need something from NASA.
Have fun coding.