I have two variables:
Start
Destinations
I want to enter start and destination in the applicable fields on this site
https://www.google.nl/maps/dir///#53.0845956,6.814237,13z/data=!4m2!4m1!3e0
So that the distance between the two locations is visible.
Any suggestions how to get this done?
You can use the directions action of Maps URLs:
https://developers.google.com/maps/documentation/urls/guide#directions-action
For example:
https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling
Related
I need to Geocode all the branches of a chain within a country or state currently I am able to fetch a single result but I need to get the data for all the branches.
https://maps.googleapis.com/maps/api/geocode/json?address=macdonaldsIndia&key="MY-API-Key"
I think I am missing some extra parameters that need to be passed in the api.Please suggest if I am missing something
Thanks in advance
You should look into Places API web service. With nearby search or text search you can get up to 60 results.
For example if I search 'macdonalds India' for location 28.661898,77.227396 with radius 50km I can get 22 results. 20 results in the first page and 2 results in second page that I get using page token parameter.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=macdonalds%20India&location=28.661898%2C77.227396&radius=50000&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/place/textsearch/json?pagetoken=CpQCDwEAANFmh2yBVwmsgsOuEDlbKLLHXYhkn7WZNsstXOHBatJm_Js2MwEPSwHb16ICXzdt5PYu37NYPTr17MBdM6c0fIqjlB7V5otC-55bjde7Ns3l9igjMvu_hePMn03WXiRaeT7PQ8eoVTNAJQu0OrINTFtNNtU7xCm1p6UIGAzMm_phr_ZL955wTTPtqWq3XadfsdAgkwdrl2lQEbbYXhikwo-SrSfKoH2scOYrdJQ4y3SaPx95BKLPjAz8D_RfncXzQ4jVJeamuITQXMAjr1DbzKPFFNiCP3Yq_Ps7iUiUZRW8cSi5XB9RGjQN8zCQCTKWYwTWCdwfz8f49dKmj8GLw0mMfLwjJaE9tNaT1ZiEB8FMEhAD9pDF_U4CbEN8qFcgEJWFGhQ0qCZwK5EHNlVqGqk9hCYpHw9p0Q&key=YOUR_API_KEY
Visually it looks like
Hope this helps!
I am working to get the latitude and longitude of nearest POI like airports, schools around a secondary latitude and longitude. So far i have searched and found the following API
http://maps.googleapis.com/maps/api/geocode/json?address=airport,Nashik&sensor=false
Unfortunately it works with the address instead of the secondary latitude and longitude. and if I insert the latitude and longitude it gives me the address of that point.
Is there a way to find the nearest airport(latitude,longitude) from the provided (latitude,longitude). I am trying this in PHP.
Please take a look at Google Places API
It's not that it fully meets your requirements and it has its limitations ("the maximum allowed radius is 50,000 meters", "radius must not be included" if you specify rankby = distance), but you can give it a try anyway.
Your requests could look like this
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.712784,-74.005941&rankby=distance&type=airport&key=<Your API Key>
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.712784,-74.005941&radius=50000&type=airport&key=<Your API Key>
You can use Aeris Weather api. Here's the documentation https://www.aerisweather.com/support/docs/api/reference/endpoints/places-airports/
You'd want to use closest action with largeairport filter to avoid smaller/non commercial/military airports
ex: https://api.aerisapi.com/places/airports/closest/p={lat,lng}&limit=5&radius=50miles&filter=largeairport&client_id={ID}&client_secret={SECRET}
You can query using other place params too https://www.aerisweather.com/support/docs/api/reference/places/
A PHP package for the api https://packagist.org/packages/mariohbrino/aeris
They have 6 months free trial and then its $23/month for basic plan.
I am working on a search plugin for our website that allows users to search any location with the Google Places API and list our apartments and their distance to that location.
To restrict the search for the users I added some possible restrictions to the method: getPlacePredictions() that can be used within the Google Places API object google.maps.places.AutocompleteService().
Country: only Germany
Preferred search Area: northrhine-westfalia (a region in germany)
function pacGetSuggestions(searchString) {
// set autocomplete options
var pacOptions = {
input : searchString,
componentRestrictions : {country: 'de'}, // restrict results to germany
bounds : pacDefaultBounds, // add search area
};
// get suggestions
PAC.getPlacePredictions(pacOptions, pacDrawSuggestions);
}
this works fine so far!
My Question:
How can I limit the results by specific location-types? Is there any way?
Example:
I don't want users to be able to search for hotels/hostels and so on, because that would be direct competition for us.
If the user types "Hil" for "Hill-Street" or "HillyBilly Pizza Place" then she should not get the "Hilton Hotels, Somethingstreet..." displayed.
Is that possible?
Here you can find supported types:
https://developers.google.com/places/documentation/supported_types
You can filter by country as well:
components — A grouping of places to which you would like to restrict your results. Currently, you can use components to filter by country. The country must be passed as a two character, ISO 3166-1 Alpha-2 compatible country code. For example: components=country:fr would restrict your results to places within France.
https://developers.google.com/places/documentation/autocomplete
I hope it helps you.
I have use the code given below, please copy and paste in your URL, which gives latitude and longitude of a specific place.
But when I have used the same call with wrong place it returns latitude and longitude. How to check whether it is right and wrong?
http://maps.google.com/maps/api/geocode/json?address=dubai+United+Arab+Emirates&sensor=false
http://maps.google.com/maps/api/geocode/json?address=anu+India&sensor=false
Thanks
A typical scenario for using geocoding will be when you know that the address exists and you want to get the location coordinates, maybe to mark on a map. When you search an address in google geocoding api, it will find exact matches and also partial matches to correct for cases like spelling mistakes or multiple spellings in use. Due to partial match, when you search for a word, words close to that in terms of the letters used and the number of letters present will also be found. You can explore 2 options to refine the results:
1, If you want to avoid partial matches , you can try component filtering , where you specify filters on components like locality, country , etc and only exact matches will be returned.
2, You can process the json result in your code by retreiving different components and doing comparisons and taking only cases matching your requirement.
can I put more than one route on one map?
Here is only one connection
http://code.google.com/intl/pl/apis/maps/documentation/javascript/examples/directions-waypoints.html
For example I have 4 points on one map: A, B, C, D. Two connection A-B, C-D.
Is it possible?
EDIT
Points A-C and B-D should be disconnected.
Yes. From Google's own examples you can see multiple routes on a single map.
You will just have to compute two different routes and show them (A-B, C-D) as in the examples you have. Just do that twice for each route.