Find closest airport (Lat,Lng) using provided Latitude Longitude in PHP - google-maps

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.

Related

How do I get the hourly forecast from api.weather.gov for Texas stations or zones or offices or gridpoints or anything else?

I am trying to get the hourly forecast from api.weather.gov
I have one gridpoint working for Indiana.
https://api.weather.gov/gridpoints/IND/56,65/forecast/hourly
I was given this information and it is valid. What I need is the hourly forecast in the state of Texas for every stations or zones or offices or gridpoints or anything else.
How do I do that?
As long as you have the latitude/longitude of the location you want the forecast for, then:
Get the point metadata from https://api.weather.gov/points/{lat},{lon}
Follow the link in the forecastHourly property to get the forecast
This is preferable to constructing the URL as in the other answer, as your program won't break if the URL scheme changes in the future.
Looking at the api documentation found HERE and HERE, you are calling the /gridpoints/{wfo}/{x},{y}/forecast/hourly call which will return the hourly weather forecast for the specified weather office {wfo} at the specified x-y coordinates. You can find a list of the weather offices HERE. Finding the X-Y coordinates for the weather offices may be a bit more tedious to find on the web.
If you happen have access to the GPS coordinates that you are working with you can use the /points/{x},{y} API call to get the information on the closest weather office to then pass to the /gridpoints/{wfo}/{x},{y}/forecast/hourly API call.
The flow of your application can look something like this:
Step 1: Get your map Geo coordinates. In my case, I am at 35,-106
Step 2: Make a call to the weather.gov API: https://api.weather.gov/points/35,-106. You will be presented with some JSON data. Look for the cwa key in the properties object. That will be the forecast office to pass into the next api call. In my case, the key is ABQ. You also need to find the gridX and gridY keys in the properties. These are the XY coordinates that you will use for the {X},{Y} parameters in the API call. In my case X = 121 and Y = 112.
Step 3: Make the final call to the weather.gov API: https://api.weather.gov/gridpoints/ABQ/121,112/forecast/hourly

How can I know if there is a restaurant at given latitude and longitude location?

How do I know if there is a restaurant at a given lat-long location?
Can we use google maps/ google places/ Yelp/ FourSquare for the same?
Input : lat, long pair ( 1.280634,103.845392 )
Output : Meii Sushi
You could use the Foursquare API and search for venues at that location with the following request. Just pass your latitude & longitude in the ll param and set the radius around that point in meters in the radius param.
GET https://api.foursquare.com/v2/venues/search?ll=44.3,37.2&radius=200
With the categories field that is provided in the response you can check whether the place is a restaurant or not

Geocoding: call longitude latitude from mysql table

I'm not very good at programming and just a beginner. My English is not that good, so I hope you can understand my question.
I'm interested to make a map like this but with a few modification: https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple
I have a mysql table with 3 columns: unit, lat, lng.
I want to make a map where user input the unit name, then it will look up for the value in mysql table, take the longitude latitude value, and display the address in google maps marker tooltips.
How do I do that? Thank you before!
You want to do this you need to learn webservices then only you can access you table.
Use this for restful webservice
using geocoder you can find the address corresponding lat and lag
use this website

Get latitude and longitude of address in Asp.net?

How can I get a latitude and longitude of some location in asp.net MVC4?
For example how can I get the latitude and longitude of Hafeez center, Lahore, Punjab, Pakistan?
You can use the google GeoCoding service to convert an address to a set of coordinates.
For example for your address you would call:
http://maps.googleapis.com/maps/api/geocode/xml?address=Hafeez+center,Lahore,Punjab,Pakistan&sensor=false
My recommendation would be to do something like:
var responseDocument = XDocument.Load("http://maps.googleapis.com/maps/api/geocode/xml?address=Hafeez+center,Lahore,Punjab,Pakistan&sensor=false");
Then read the xml to the information you need.
Edited to add - make sure you check google's terms and conditions, they prohibit some types of applications!

Cross Street Coordinates

I want the latitude and longitude of two street that cross from the Google Geocoding API.
It should be a simple matter to determine the syntax, but I am unable to find any examples.
I can, however, offer and example that doesn't work:
http://maps.google.com/maps/api/geocode/json?address=maple+street+and+main+street,+Anywhere,+MO&sensor=false
The "and" keyword is wrong. Is there a proper syntax, or should I just kill myself?
I think you've got the right syntax. Your example doesn't work because there is no Anywhere, MO so the service is returning the only thing it recognized, which was the state of MO.
The API correctly returns locations of type intersection for the queries like:
http://maps.google.com/maps/api/geocode/json?address=Main%20Street%20and%201st%20Street,%20Springfield,%20MO&sensor=false
and
http://maps.google.com/maps/api/geocode/json?address=Amphitheatre%20Parkway+and+Charleston%20Road,+Mountain%20View,%20CA&sensor=false