How do i use the google maps on android to get the same script as the website
I want it to search the nearest mcdonalds from the location and have all the markers from the website
https://mcdonalds.com.au/find-us/restaurants
That is possible. You can do that using Google Places API and specify in the parameters for types=restaurants.
This is a tested example:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&types=restaurant&key=YOUR_API_KEY
Now this will fetch all the restaurants in the radius you have defined in the proximity of your current location or the input location.
You can further filter results by writing code that checks if {name name = Mc Donalds} then only fetch the results else {do nothing}. This would give you results just for McDonalds in 500 meter of radius from the specified location.
Hope this Helps!!
Related
I implement to get distance between two location in google map in android but i have not idea how to get travel time for this two location ? I refer many example but i can not understand. Give me example
You can get travel time from [Google Direction API] -
Link: https://developers.google.com/maps/documentation/directions/start#sample-request
Provide your origin & destination in the URL and you'll get a JSON Response.
You can then find travel time in the response as:
routes(JSONArray) -> legs(JSONArray) -> duration(JSONObject)
Reference Link: https://developers.google.com/maps/documentation/directions/intro#DirectionsRequests
I have used Google geo address and using lat/long have got the address. How do I determine if I am on road on not? Basically hit-test for road? I am currently using location manager for lat/long and the GeoAddress is same for on road and next to road.
Final Solution
Use reverse geocoding via the Google Geocoding API.
The term geocoding generally refers to translating a human-readable
address into a location on a map. The process of doing the converse,
translating a location on the map into a human-readable address, is
known as reverse geocoding.
The Geocoding API supports reverse geocoding directly using the latlng
parameter. For example, the following query contains the
latitude/longitude value for a location in Brooklyn:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
The docs explain how to interpret the json results but StackOverflow has various answers addressing more efficient ways to parse the data.
https://stackoverflow.com/a/8095967/1085891
https://stackoverflow.com/a/8314094/1085891
https://stackoverflow.com/a/6335080/1085891
Possible Solutions
Getting the nearest street/road coordinates in android - the answer to this question may point you in the right direction.
You can use directions api directly: http://maps.googleapis.com/maps/api/directions/json?origin=51,19&destination=51,19&sensor=false
Could you use the API to find directions which would then provide the closest road?
Stick position to road on android maps v2
GPSLocator - App to Find Current (Nearest) Location using GPS - possibly helpful; not so sure on this one.
Snap to Roads Android - Exact same question
Quick Search Results
Snap to nearest street
Maps API Blog using GDirections.loadFromWaypoints
Finding nearest street given a lat-long location
Driving route from my location to destination in Google Maps Android API V2
Unsolved Similar Questions
Trace the location only on Road in Google maps V2 android
https://stackoverflow.com/questions/18081417/google-maps-v2-snap-to-road-issue
See fiddle.
It can be done so much easier with OSRM (nearest) webservice. Make a GET request like:
const url = '//router.project-osrm.org/nearest/v1/driving/';
fetch(url + coord.lon + ',' + coord.lat).then(function(response) {
return response.json();
}).then(function(json) {
if (json.code === 'Ok') {
console.info(json.waypoints[0].location);
}
});
Which is a road/street coordinate.
References — Project-OSRM
I'm building a mobile-version of a website, trying to have one-click link to launch Google Maps with driving directions to the business, from the user's current location. I have it working fine for the iPhone, but when testing on Android, it views 'Current%20Location' and tries to find a business called 'Current Location'. Here is my current code:
Get Directions
I need a universal string to search from the current location, and can't find a definitive answer anywhere online.
Thanks in advance for any help!
I am doing the same thing and now have it working on Android. I don't have an iPhone so I have no way of testing on that. You should leave the saddr parameter blank in the URL, and Google Maps will then prefill it with the user's current location. Also, use + signs instead of spaces in the destination address. Here's the corrected URL:
http://maps.google.com/maps?saddr=&daddr=123+Street+Rd,Cityville,MD,21098
Use the google gps api to get the currentlocation and pass it to maps. Even better I think there's an action to open the built-in maps application asking it to route from current location to your address.
This article on location services should help http://developer.android.com/guide/topics/location/index.html
If you're trying to do it fully through the web, I think the user has to enable location services on the google webpage for it to work.
Also, check out this javascript library that provides a platform neutral api for gps services on most devices http://code.google.com/p/geo-location-javascript/
Google Maps with directions from current location
https://maps.google.com/maps?saddr=&daddr=35.658157,139.697174&sensor=TRUE
https://maps.google.com/maps?saddr=&daddr= PLUS
"location's_latitude" PLUS
"," PLUS
"location's_longitude" PLUS
"&sensor=TRUE" // for getting your current location
Probably the most accurate way using lat and long
<span class="addressAt">
<a href="http://maps.google.com/maps?f=d&hl=en®ion=US&doflg=ptm&geocode=&saddr=&daddr=41.75553,-88.322048" target="_blank">213 S River St
Aurora, IL</a>
</span>
This is the only way to get an accurate "my location" on the google maps mobile site. Replace the coordinates(41.75553,-88.322048) with your locations coords. All other ways just wrote in my location as the start address without actually getting the real time location.
Is there any API in google for finding nearby location or Landmarks for my current GPS lat&long position.
Use this :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);
After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.
If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this
http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago
more info :
http://code.google.com/apis/websearch/docs/reference.html#_fonje_local
This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.
hope it helps...
i have successfully displayed google map in my app . but i am not able to search the specfied location . can u please put the code snippet or any link available for the code .
To get a location (latitude and longitude) from a location name(e.g. "paris" or "japan"), use Geocoder.getFromLocationName()
To display a specific latitude/longitude on the map use MapControl.setCenter()