This is a drupal 7 module that output json inforamtion of the closest location (geofield)
Thanks to hakre who has provide a good php code to find closest longitude and latitude in array see http://stackoverflow.com/questions/9589130/find-closest-longitude-and-latitude-in-array
If you are using location instead of geofield module this can be without code see this blog post :http://www.tylerfrankenstein.com/code/drupal-build-mobile-app-geo-locate-node-content