How do I plan a users routing in chronological order? - android

STILL DESPERATELY LOOKING FOR ANSWERS
I have integrated Google Map's dynamic geocoding in my android project(when the user types an address, it goes there and places a marker). My plan however is to let someone else plan the users schedule for the day.
For example, someones mother wants her son(the user) to do some errands for her. So she opens the app on her phone and types in the places she wants her son to go. The son get the places he needs to go in a chronological order, i.e, the vacuum cleaner store, the hardware depot and then the supermarket. First, the route to the vacuum cleaner store(from his current location) shows up. He goes there, an then presses "done". Then the route from his location to the hardware depot is shown,and so on and so forth.
Not necessary, but appreciated: He should be able to open a navigation drawer with all the errands in a list format, from the first errand to the last.
To summarize, how do I plan someones route in chronological order? I know I am asking for a lot, but if anyone could help me out, that would be great. I would literally sing your praises.
Thanks for reading this wall of text!

It is just an idea, maybe you can try to use waypoints under the Google Maps Directions API.
You can use this waypoints to calculate the routes through additional location.
Here is an example request using waypoints in Direction API
https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&key=YOUR_API_KEY
You can supply one or more locations separated by the pipe character (|), in the form of an address, latitude/longitude coordinates, or a place ID.
Although this is in JavaScript, this is an example on how to use waypoints.

Related

How to get distance between two points from waze

i am developing an app in android that must recieve the distance between two points from the user after traveling between them, and that input must be validated, for that i'm thinking of using an API to get the information and make the validations later. I know that it's not the op to ask the user to enter that kind of input, but that's not on me.
For example, if the distance between point A and point B is 13 km according Google Maps Distance Matrix API, i got from the waze api like 18 km. The approach of the app is one about transport so i would prefer to use waze information because it's more accuarate in terms of road traffic.
So, there's any way to take the distance between two points from waze?
more exactly, this one:
Any help would be appreciated
PD: sorry for bad english
I'm not certain whether you're still looking for an answer, but in theory you could call the Waze routing server in the same way as the Waze Live Map calls it.
The following URL is the request sent to the Waze routing server when I calculate the route between Antwerp and Brussels in Belgium.
https://www.waze.com/row-RoutingManager/routingRequest?from=x:4.4024643+y:51.2194475&to=x:4.3517103+y:50.8503396&at=0&returnJSON=true&returnGeometries=false&returnInstructions=false&timeout=60000&nPaths=1&clientVersion=4.0.0&options=AVOID_TRAILS:t,ALLOW_UTURNS:t
Note: make sure to properly encode this URL when using a script. Those colons and commas might cause issues otherwise.
To calculate the length of a route, you'll need to go through all the traversed road segments and make a sum of the length fields (expressed in metres, if I'm not mistaken).
Do note that the results will differ from time to time as Waze includes historical traffic data in its results and will decide to make detours, which may not be wanted for your use case.
I would also strongly suggest to look into the legal status of doing this, though I suspect it won't be a big issue if you're not using this data to make a competing service or 'forget' to mention you're using Waze data to calculate things.

Get total "Areas/Zones" in which I am currently in, based on Current Location

Let us suppose we have three hotels:
Hotel A (popular in 1 km radius), Hotel B (popular in 2 km radius) and Hotel C (popular in 4 km radius). A car enters and is at some position. These Hotels (or any other place) is added by us and is custom.
Problem is I want to find the hotels which have popularity/influence at my current location.
And I want it to do totally with the help of Google Maps. Is it feasible ? on Android (optional)? Please ELI5.
Google Maps API has a function called computeDistanceBetween. It "returns the distance, in meters, between two latitude/longitude coordinates". Circle has the Center and Radius properties. So you need to calculate the distance between the center of a circle and you current location. If it's less than the radius of the circle, than it means your current location is within the circle.
Simplifying is key
Although I understand your objective (get a list of all hotels near you) I believe your explanation threw many people off guard. You don't need to triangulate positions and calculate radius of circles - not with Google Maps APIs and Services.
All you need to know is if you want a solution for front-end, back-end, or mobile
Google Maps Places API Web Service (back-end)
The Places API has a very useful feature called "Places Nearby". To quote the documentation of this feature:
A Nearby Search lets you search for places within a specified area.
You can refine your search request by supplying keywords or specifying
the type of place you are searching for.
Which looks exactly like what you need, right ?
To make a request from a server to the Places API Web Service looking for nearby places, you can do the following:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&name=cruise&key=YOUR_API_KEY
Do remember to change the key=YOUR_API_KEY to a valid key field. The example showed will look for restaurants in a radius of 500 meters around the location of -33.8670522,151.1957362.
There are a lot of parameters to this and you can read more about this in the following documentation
https://developers.google.com/places/web-service/search
Google Maps JavaScript API with Places Library (front-end)
If you however don't have a central server or service to make requests for you, making the clients send the requests directly is also an option.
In this case, there is the JavaScript API. The JavaScript API is a client-side friendly API that re-uses some of the Web Service's features.
In this case, you can use the JavaScript API in conjunction with the Places Library for it. According to the documentation, this API allows you to do "Nearby Search Requests":
A Nearby Search lets you search for places within a specified area by
keyword or type
An example of such a request can be seen in a live example in the following link https://developers.google.com/maps/documentation/javascript/examples/place-search
You can read more about the parameters and usage of this API and this library in the following documentation https://developers.google.com/maps/documentation/javascript/places#place_search_requests
Google Maps Android API (mobile)
From the picture you added, I assume your app will be to "use on the go" (perhaps a mobile app), or something similar.
In this scenario, using a web-server or a website could be cumbersome, as by the time you have a response from it, the car is already in another position !
To aid you in this, there is also the Android API. To use it you need to:
Download and Install Android Studio
Add Google Play Services Package (contains APIs you will use)
You can read more about this process here https://developers.google.com/maps/documentation/android-api/start
As for code and examples, I strongly suggest you check out this GitHub repository of samples
https://github.com/googlemaps/android-samples
Our Hotels may not show up on Google Maps
Unless your DeLorean takes you back to the latter half of the 19th century, or you are stuck in an island with hundreds of Meerkats, poisonous pools and a tiger wondering if he should eat you or not, Google Maps will pretty much always show you some hotels where you can spend the night.
PS: kudos++ if someone gets my references :P
Adding Hotels and Places to Google Maps APIs and Services
If this is still not enough however, there is still a way you can fix it. You can add Hotels addresses and Places to Google Maps by using one for the two following methods:
Send Feedback
Use Maps Maker
Send Feedback
The "Send Feedback" feature allows you to send feedback to Google's data teams for review. Once approved, the data is added to Google's database and will be available to all Google's customers. You can do this by following the steps described here https://support.google.com/maps/answer/3094045?co=GENIE.Platform%3DDesktop&hl=en
Please do note however that the review process for your feedback will take some time, so don't expect anything instantaneous !
Use Maps Maker
Alternatively, you can use Maps Maker. This tool allows you to do edits and add information to our Services in a more streamlined manner.
At first, your edits and suggestions will still be reviewed, and it will usually take less than two weeks to get something approved.
However, with time, as more and more of you suggestiogns are approved, you gain reputation, and when you have a lot of reputation, your suggestions will be pretty much automatically added.
Before using it however, make sure you have a look at the list of supported countries.
Also, if language is important, you may want to consider it as well, by checking the list of supported languages.
I really don't want to add anything to Google Maps
Sometimes the whole business is data itself, so giving it out freely is not an option.
In these cases, you will have you own database, which your services will have to check.
In cases like this a custom solution for your system is needed, but in order to suggest a few more ideas, more information is needed.
Hope it helps !
Your approach should use fast approximate calculations without relying on apis, and then api usage can be used to enhance user experience.
You know the coordinates of the car.
You know the coordinates of each of the hotels.
Assign a popularity weight to each hotel based on your criteria or data you have. e.g a hotel having more user reviews or transactions or bookings will have higher influence, or if you want to personalize, a hotel which suits the loggedin user's budget preferences ( based on past data or settings ) will have higher influence. Lets call this popularity value p1,p2..p3 etc.
Find all hotels that lie within a threshold range, say 5kms within current position of the car. This can be done using a geospatial query in any major storage database ( for example if your hotel points are stored in MySQL, or mongodb ), or if you are using a hotel data api, get the nearby hotels,or all hotels of that city, and prune them based on distance from car's current location.
For linear distance between the car C, and the hotels H1, H2... use Haversine formula , this will give you distance between the Car and any hotel along the Earths curvature. ( Actual road distance might vary, as roads are directions aren't straight and involve turns etc). But this will give you a fast approximation of distances D1 between C & H1, D2 between C & H2 etc...
Now decay the popularity score P1...PN of each hotel based on distance between the Car C and the hotel H. For example if hotel H1 has popularity score P1= 90, and hotel H2 has popularity score P2=90, but C <---> H1 distance is 10kms, and C<--->H2 distance is 2kms,
then H2 will have more influence on the current location compared to H1.
A simple formula can be LocationInfluence = PopularityScore/ log(Distance), you can optimize this based on your use case.
Now for the most influential hotels H1,H2,H3... use DistanceMatrix api to find actual driving distance, you can also use google maps directions api for Android or Javascript to show driving directions to the user, from location till the hotel.

Sharing google map V2 with polyline drawn on the map (Reusable)

Hi, I am new here. So if I have posted my question in the wrong place or any mistake, please do enlighten me. I have more or less browse through many sites searching for an answer but I could not find anything.
Let me briefly explain about how my Android apps will work:
1. There's one part of my apps, it will track the location of the user via Wi-Fi and GPS.
2. It tracks the distance traveled, speed, time taken and etc.
3. Now I planned to add in another feature in, which is:
-> I want to share the route with the map which the user has ran through to Social networks where another user can press into it and the apps will automatically receive the route and map which previously ran by the first user so that he/she can challenge the first user by running the same route as the first one's route (guided by the polylines drawn on the map). Then the apps will be able to track the second user, and a New polyline will be drawn on the route to track his/her progress. (distance traveled, duration and polyline drawn on the Google map)
Ques: How am I suppose to share the map together with polylines which are accessible by others.
I guess you'll have a server side for this as well, so if a user runs, the result will be uploaded to it. You should generate a unique ID for every run like this, and store it connected to the data needed to be stored (distance, speed, etc), and only share a URL from your app, and let the server handle the rest.

How do I find nearby app users in android?

I am making an application which needs to be able to find people nearby, who are users of my app.
I looked at many answers of precedent similar questions, and it seems I have no choice but to keep uploading a user's current location to the server, and get nearby users' list when necessary.
Then my question is,
1. To get the nearby list, there should be some algorithm or function which calculates the distance. Then doesn't that mean I have to get all distances between my location and the rest of the app users? So the server returns certain number of users who have the least distance results. If I'm correct, wouldn't there be memory or time issues?
2. This might sound weird, but how about this.
I'll probably send latitude and longitude information or address information to the server. Can't I compare those strings with all users' address list from the first numbers or letters using string searching algorithms or something?
For example, if my last updated address is 'abcde' on the server, the algorithm will look for addresses that start with 'a', if finished searching, then look for addresses that has 'b' after 'a', in other words 'ab'.
This might not be a right solution, but I thought it might work because the address will be saved in same forms.
To find nearby users efficiently, you need a spatial index. See: Hierarchical Triangular Mesh.
You also can use one of the databases that support spatial queries.
I'll probably send latitude and longitude information or address information to the server. Can't I compare those strings with all users' address list from the first numbers or letters using string searching algorithms or something?
That won't work with latitude and longitude because that way you can only search for proximity in one dimension. For example, 30°N 30°E will appear closer to 30°N 90°E than to 31°N 30°E.
It may work with addresses, but only if they are reliably connected with coordinates (i.e. not typed in by users), and only if you don't mind that users 200 meters apart but on different sides of some administrative border will not count as close to each other.
You can use the REST Api from Server Side using PHP which takes the Current LAT LONG of all user for your app From User's Android Phone at certain time Interval Lets Say 5 min & it returns the Nearest Location,Address Distance.You need to call the Api # certain time Interval & in response From Server You will get all the Details What You Want Like Nearest Location of Your App user, Distance and Other Thing.
Why i am suggesting this way because to do Computation from Android Side Will Affect the App Performance Having Battery Issues So its better to Have All computation from Server side instead of Android(User) Side
hope this will helps you.
I am a bit late here but for anyone who comes across this question, assuming you are using Firebase for your database, your best option would be GeoFire using queries around a specific point in coordinates and a radius in km. Here is a link to the github repo https://github.com/firebase/geofire-android which explains everything in detail.

How can I take a text query, and get a location in Android?

I was wondering how I can channel or simulate Google Maps just in the sense of a user types in a location in text, such as a restaurant name and a city name. Then Google suggests 5 or so places they have indexed, and presumably they know the GPS coordinates because Google then puts them on a map. I want to be able to use that feature- not the map, just getting the location.
My goal is for a user to type in a query, 5 options or so to be shown, and if they user chooses one of them, then the GPS coordinates, or a location object, is saved representing that place.
Ideally I could just send the query to Google and steal the results back to my app. Obviously building my own database of locations and an algorithm to suggest them is out of the question.
Thanks for the help and advice in advanced!
Note 1: To clarify, this does NOT involve the current position of the user/device.
Note 2: I looked at the Google Maps add-on API, but it looks like that is for a visual map, not the querying a location part. You are already supposed to know your location, and it will map it.
Use geocoder.getFromLocationName, you get back a list of Address objects, in those objects you will find all the information you need about the location.
To test this on the simulator you need an image with the Google APIs included. In a device should be fine if you have the market installed.

Categories

Resources