I have 2 Place IDs I've obtained via the Google Places API, and want to display a link to the Google Maps app for directions between those 2 places.
I see that it's possible to do this with 2 addresses based on the answer at Current Location - Google Maps - Link to Directions using the saddr and daddr query parameters
I also see that it's possible to link to a map with a place ID by prefixing place_id:... in the q query parameter from this answer at Getting Google Maps link from place_id
Is there a way to have a directions link with the Google place_id? I tried a URL like:
https://www.google.com/maps/dir/place_id:ChIJp4JiUCNP0xQR1JaSjpW_Hms/place_id:ChIJp4JiUCNP0xQR1JaSjpW_Hms and it doesn't seem to work
In order to open Google Maps directions mode with place IDs you have to use Google Maps URLs. The Google Maps URLs in directions mode support parameters origin_place_id and destination_place_id.
Create the following URL for example (note that origin and destination parameters are also mandatory as per documentation)
https://www.google.com/maps/dir/?api=1&origin=Yukar%C4%B1%20Bah%C3%A7elievler%2C%2070.%20Sk.%2017%2FB%2C%2006490%20%C3%87ankaya%2FAnkara%2C%20Turkey&origin_place_id=ChIJp4JiUCNP0xQR1JaSjpW_Hms&destination=Be%C5%9Fikkaya%2C%202044%2F1.%20Sk.%2C%2006230%20Alt%C4%B1nda%C4%9F%2FAnkara%2C%20Turqu%C3%ADa&destination_place_id=ChIJn-ZptRFT0xQRGUyoJX2s8Wc
Have a look at the documentation for further details.
I hope this helps!
Related
I currently have an application which takes a a start and end point from a user and sends a request to the google maps directions API, for example: https://maps.googleapis.com/maps/api/directions/xml?key=my_key8&origin=M460PU&destination=NN36NW&sensor=false&mode=driving&units=imperial&departure_time=1501752779
We then display the estimated journey time for a given route. The user has asked if it's possible for us to include a link directly to Google maps so that they can see the route on the maps and make sure it looks ok.
I've seen previous questions such as this one: Link to Google Maps but that seems to be a solution for a simple Google Maps search, where as in my case I want to see a route from the directions API.
I'm trying to figure out if I there's a way I can take the data from the Directions API response and plug that in to a http://maps.google.com/maps URL that the user can click on. Has anyone ever had any success doing this?
As mentioned #geocodezip you should use Google Maps JavaScript API or Google Static Maps API in order to show exactly the same route as the output of Directions API.
There is also an option to open Google Maps web site or native app using the Google Maps URLs. You can have a look at the documentation to figure out how to create the URL:
https://developers.google.com/maps/documentation/urls/guide#directions-action
The only issue is that the Google Maps URLs doesn't provide any parameter for departure time, so you will always get routes for "Leave now" that might have discrepancies comparing to a web service that was requested for a different departure time.
Based on your question I think the Google Maps URL might be
https://www.google.com/maps/dir/?api=1&origin=M460PU&destination=NN36NW&travelmode=driving
I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?
I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:
https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation
https://developers.google.com/maps/documentation/urls/guide
So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be
https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4
Hope this helps!
Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map
google developer doc
The URL for a specific Google Place is returned by the places details API endpoint.
If for example you query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY
You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661
The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]
The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.
Set this parameter to "m" for a street map and "k" for a satellite map.
A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.:
https://www.google.com/maps/place/Starbucks/#43.088554,-88.06579,17z/
If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.
So I have successfully found directions to get some lat/long A to lat/long B using the Google Maps v3 directions api.
I want to be able to take a route from this api and give the user an option to view them on the google maps website.
I dont want to show the route on my website but only show the time it would take to get from A to B.
is this possible?
thanks!
https://developers.google.com/maps/documentation/directions/#Limits
The Directions API may only be used in conjunction with displaying results on a Google map; using Directions data without displaying a map for which directions data was requested is prohibited. Additionally, calculation of directions generates copyrights and warnings which must be displayed to the user in some fashion. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
I'm quite new to the Google Places API. What I want to achieve is create a simple search box where people can search places based on Google places, and choose one of them to get the coordinate (latitude, longitude).
Currently I'm using the Google Places API. All the steps are pretty straight forward, but after using it for a couple of day, I realize that sometimes the result from the Google Maps search box is better than the Google places API.
Below is what I test right now for Google Maps and the Google Places API
I test the result from the Google Maps search box with maps.google.com and see all the autocomplete.
I'm using the Google places API without any limitation in radius (orderby=distance), sensor is false, I put the user current location in the location parameters and the text into the keyword field.
Based on this configuration, the results are different. May I know if someone knows and would be willing to share how to configure the Google Places API URL to get the same results as with the Google Maps search box?
Or is it unachievable? That is, will the Google Places API search result not be as good as when we search in Google Maps? If so, is there any policy that does not allow people to only use the Google search box and the coordinate result without showing the map?
I believe Google Maps autocomplete uses a combination of results from the Place autocomplete and Query autocomplete services. Based on your mention of rankby=distance, it sounds like you're using the nearbysearch service, which will return somewhat different results from the autocomplete services. Have a look at the Google Places API documentation for the details of using the autocomplete services.
https://developers.google.com/places/documentation/
I am new on google maps devlopment. I am using google map javasccript api v3.
using the below url
url : https://developers.google.com/maps/documentation/javascript/tutorial#api_key
I was able to generate the key that is required to generate/display map. I tried a sample example for this.
What I would actually like to know is: can we add multiple instances of google maps on a page at the same time?*
Also, I am bit confused like there is a limit for number of times a map can be loaded in a day (some 25,000) and if exceeds that there would be charge for the next request for that particular map?
1) In the Google Dev Console, it states that the Android Google Maps v2 call does not have a limit whereas regular Google Maps v2 has one set at (25,000). I would link to the console, but you have to be logged in.
2) No, I do not think that you can have multiple instances of maps running on one activity at a time.
Hope this helps.