Hi,

I have used Google Maps to do something similar (with my Tweet search
app - www.tweedar.com).

Basically the Geocode function in Google Maps allows you to look up a
name and it will return you a set or GPS coords. In Tweedar I have
used this within a Flex application so the code is in ActionScript,
but I did a map application for Facebook as well and I used a call
from PHP to do the same thing (this was taken from example code I
found on the net). You can then call this function from PHP (or as a
HTTP call) and get the c0ords back from a location name ( i.e. "San
Francisco, USA")  - you will need  a key for Google Maps as well.

/**
 * Look up a set of GPS coords(lat &lon) from a text location/address
 *
 * @param string $location:  the text address(comma delimited)
 * @param string $key:  a valid map key on Google MAPS
 *
 * @return an array of the result [http status, detail, lat, lon]
 */
function getGpsCoordsFromGoogle($location, $key){
        // make a REST call to google for coords of location
        $base="http://maps.google.com/maps/geo?q=".urlencode
($location)."&key=".$key."&output=csv";
        $output=file_get_contents($base);
        return explode(",",$output);
}

Hope this helps,

-Steve.
www.tweedar.com


On Feb 18, 8:17 pm, Pete Warden <searchbrow...@gmail.com> wrote:
> I needed a way for users to be able to enter readable place names and
> do searches restricted to the neighborhood. The search API only
> supports lat,long so I had to implement some geocoding to translate
> names into coordinates. I ended up using Yahoo's free GeoPlanet
> service, with 50,000 requests possible per month.
>
> Since I couldn't find any other public examples of how to do this
> (though I'm sure this must be in a lot of code out there) I put up my
> sample 
> code:http://petewarden.typepad.com/searchbrowser/2009/02/how-to-emulate-ne...
>
> It's a small PHP file, and works just like the normal search API call
> but with an additional near argument that gets translated by the
> geocoding. I'd love to see some more explanation on the docs wiki of
> this sort of workaround for 'near', but it seems that it's only
> editable by Twitter employees? Facebook's more open editing policy
> seems to work well for them.
>
> cheers,
>            Pete

Reply via email to