user3703404
user3703404

Reputation: 41

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

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.

Upvotes: 2

Views: 10834

Answers (2)

Manoj
Manoj

Reputation: 5602

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.

Upvotes: 0

Anatolii Suhanov
Anatolii Suhanov

Reputation: 2682

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>

Upvotes: 1

Related Questions