Find nearest transit station / stopover (bus, train etc) in Google Maps - java

Is it possible to find the nearest bus, train, or other public transit?
The 'nearest' is a separate case, but is it just possible to find them?
They are tagged, but I want to know how to access/find them.

I don't think that this is supported in Google Maps yet, finding the nearby public transport locations of a spot.
The only workaround I could think of is to use the location you want to get the nearest public transportation as a starting point of a directions calculation.
As the destination, you choose any random location that's a little away but far enough so the route would require a public transportation (not just walking).
Then you could fetch the first public transportation from the resulting data.
For example:
if you have calculated a route like this:
http://maps.google.com/maps?f=d&source=s_d&saddr=15+Vanderbilt+Avenue,+New+York,+NY+10017+(Grand+Central+Terminal)&daddr=central+park&hl=en&geocode=CUdYBSaiyFjNFWbXbQIdIDOX-yFZWQrti_yyniknhhaRAVnCiTHFY7RT82_HCg%3BFT0ebgIdVT6X-yn1xwsBmljCiTG2GSD9L5ZZwQ&mra=pe&mrcr=0&dirflg=r&ttype=dep&date=06%2F22%2F10&time=10:34am&noexp=0&noal=0&sort=&sll=40.764379,-73.974187&sspn=0.093872,0.154324&ie=UTF8&z=15&start=0
you would just add the parameter &output=json to the url and could fetch the data as json format.
http://maps.google.com/maps?f=d&source=s_d&saddr=15+Vanderbilt+Avenue,+New+York,+NY+10017+(Grand+Central+Terminal)&daddr=central+park&hl=en&geocode=CUdYBSaiyFjNFWbXbQIdIDOX-yFZWQrti_yyniknhhaRAVnCiTHFY7RT82_HCg%3BFT0ebgIdVT6X-yn1xwsBmljCiTG2GSD9L5ZZwQ&mra=pe&mrcr=0&dirflg=r&ttype=dep&date=06%2F22%2F10&time=10:34am&noexp=0&noal=0&sort=&sll=40.764379,-73.974187&sspn=0.093872,0.154324&ie=UTF8&z=15&start=0&output=json
In this sample you would get "Bus M02" as the first public transportation.
But this is really a very bad workaround. I think gotta wait until Google opens the API for that.

Related

Limit Android Google Places API to search only given area

I`m using Android Google Places API to autocomplete streets and addresses. The problem is that it gives all streets from a whole country. Of course I added bounds to limit place for search, but it doesnt work correctly - it gives only priority, so in other words best results will be higher in list, nothing more
So code:
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry("RU")
.build();
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.zzih(searchString) //that is for passing search string from toolbar
.setFilter(typeFilter)
.setBoundsBias(city.getBounds())
.build(this);
In short the problem is:
When I type in search something like "Lenina Street" I see a lot of useless results out of bounds set in .setBoundsBias(city.getBounds()). Just imagine that something like "Lenina Street" exists in almost every locality!
How can I fix the problem and limit search results?
P.S.
I know I can use Google Places Web API or by GeoDataApi.getAutocompletePredictions() and filter results manually,
but that means I have to write UI manually too, what I dont want to
do.
Thats even worse than I thought. Even if I get results from Web API or through GeoDataApi I have only predictions which doesnt contain coordinates, only placeId. So if I want to filter predictions by coordinates I have to do request for each placeId. In other words if I got 20 places I will have to do 20 more requests to find out coordinates.
Also I can add city name in searchString, that makes results better (but not at all) but it makes writing of address unclear and city name takes place, so its not good solution too.
I'm afraid Places API for Android doesn't support strict bounds yet. There is a feature request in Google Issue tracker to implement this:
https://issuetracker.google.com/issues/38188994
Feel free to star this feature request to add your vote and subscribe to notifications from Google.
In the meantime the workaround might be using Places API web service that supports strict bounds and implement the UI manually.
UPDATE
The feature request was marked as Fixed by Google. Have a look at https://stackoverflow.com/a/50134855/5140781 that shows how to apply strict bounds in Places API for Android.

How do I pass and extract data in googlemaps api in my android app using java?

I am new to android development but familiar with java. I want to send a request (containing coordinates of locations) to google maps api for distance matrix and later calculate the sum of distances for each point. The response from api is either in javascript or xml (i dont really know which one). How do i send the query in java and how do i extract the distances from the response?
Try using seperate classes to send and recieve data through the Google maps API. try using JSON to send aaplication data.
In order to use any thing like this (or that is owned by google etc.. ) You first need to setup a developer account at https://play.google.com/apps/publish/signup/
It does cost 25 dollars but in all honesty it's worth it as you get access to a lot of different things including the google maps api, if you're not interested in spending the $25 I would suggest looking into an alternative mapping api.
If on the other hand you will spend the money they've got some great tutorials laid out in the documentation!
A Google Maps Distance Matrix API request takes the following form:
https://maps.googleapis.com/maps/api/distancematrix/output?parameters
If you need more information, Refer to "Distance Matrix Requests".
https://developers.google.com/maps/documentation/distance-matrix/intro#DistanceMatrixRequests
You can also use the "getDistanceMatrix" that issues a distance matrix request.
https://developers.google.com/maps/documentation/javascript/3.exp/reference#DistanceMatrixService

Android Osmdroid get poins of interest from own database

This is my first time using stackoverflow because I am really desperate to solve this issue.
I am developing an app that contains information about bus stops in my country (Google maps does not work if I try to go from X to Y on a bus) so I decided to do it myself. I already tracked every stop of many buses.
I show each bus stop as overlays in my osmdroid map view, I get this information from a internal database that as I said I collected the information and is not online.
What I want to do now, is to get the user's location (lat, long) and tell him/her the closets bus stops to him/her location. I already looked at Osmdroid bonuspack and the POI feature, but what I understood is that these places (restaurants, bus stops, hospitals, etc) are already on a server.
How can I implement a POI function on my application with local information. I would appreciate any help, this is something I want to do for my community.
Thank you everyone and sorry for my poor English. I am doing my best.
You already have the coordinates of bus stops in your database, and they are displayed in an overlay. You can also get the current users location. What you want to achieve is a matter of calculating the geographical distance between two points (the user's location and a bus stop).
You don't have to implement a suitable formula yourself, e.g. have a look at the GeoPoint class. There's a distanceTo(final IGeoPoint other) method. You can instantiate a GeoPoint with known coordinates or simply use Overlay methods.
You could also achieve the same thing by querying only the bus stops that are within a certain radius of the user's location (maybe have a look at the BoundingBox)
If you want to use libraries like the BonusPack, look at the provider implementations. You could simply write your own provider for your bus stops. Have a look at e.g. this one.
> How can I implement a POI function on my
> application with local information
I assume that your question is about "how to render busstops on local device" and not "how to query my local database" and not "how to do some server-side support."
If you want to render the busstops on you local android device you can use osmbonuspack
which contain an example app that shows how to render interactive poi-s.
Unfortunately currently there is no precompiled osmbonuspack aar at jcenter/mavencentral so you have to include the sources as a local subdirectory of your project.

Create post-code based service

I want to create a United Kingdom(London focused) post code based application. For instance, one of the basic queries would be:
User comes and types their post code, determine the n most nearby objects to the post code they typed in.
I am using noSQL(MongoDB) and I benefit from DB native geo-spatial objects.
How do I link geo-spatial coordinates to UK postcodes?
Is this long-lat to postcode conversion the right approach?
Is there a service available to cover that part?
How do you convert from London post code to latitude and longitude
so that you can measure distance?
The mapping between UK postcodes and latitude/longtitude is accessible online on this site in form of CSV so it should be easily parsed. In case it wouldn't be available latter for any reasons I've mirrored it here.
As for your first three questions, as written in this post you can store entries like case class Zip(code, location) and perform lookup with $near operator on the second field.

Including waypoints in query to Google-Maps API on Android

According to this solution
Why retrieving Google Directions for Android using KML data is not working anymore?
I've got the question what is the shortest way to draw the route through the waypoints.
Implement itemizedRouteOverlay to store routes route from
start point->waypoint1, waypoint1->waypoint2, waypoint2->destination
Merge route objects and draw it as routeOverlay
Route1=start->waypoint1, route2=waypoint1->waypoint2 etc..
Add implementation of waypoints in parser
Any other, better way?
Any hints will be appreciated.
The fastest way I found is to:
add parameter waypoint with via: prefix for each waypoint to JSON URL string, so it doesn't create more than one leg in JSON (crucial part because there is only one leg support in GoogleParser provided with that example). Google offers only 8 waypoints support for non buisnes customers, so that was another problem. I've managed to bypass it by spliting route to sub-routes, where ending point of one route, was begining point of another route. Each route was stored in list as different routeOverlay object, and then one-by-one added to mapView in the loop .

Categories

Resources