tags:

views:

35

answers:

1

Is it possible to get places by latitude/longitude and radius using the Graph API (or by address/zip)? I don't see it anywhere in the documentation

A: 

I don't know much about the facebook API, but if you can pull the lat/long of two places, you can calculate their distance quite easily. Here it is in JavaScript, but it's portable to about any language:

var R = 6371; // km .. use 3963 for miles
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad(); 
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
        Math.sin(dLon/2) * Math.sin(dLon/2); 
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
var d = R * c; // km

Hopefully this helps you with your endeavor.

glowcoder
Thank you but I don't know which places are around my coordinate.
Breezeight

related questions