GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
reverse geocoding in php  XML
Forum Index -> General
Author Message
nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

Is there an example how to use reverse geocoding like nearbyplaces in php?
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

I don't have an example for the geonames services. You find a lot of other examples and tutorials on the web :
http://search.yahoo.com/search?p=php+rest

This should help you to get started.

Cheers

Marc

[WWW]
nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

I just want to know hoe the http regquest looks like in php and how I get my information returned.
geotree


[Avatar]
Joined: 23/07/2007 18:28:40
Messages: 138
Location: France
Offline

Example using PHP 5
Code:
 $url  = "http://ws.geonames.org/hierarchyJSON?geonameId=6447142";
 $json = file_get_contents($url);
 $data = json_decode($json, true);
 var_dump($data);


Note : json_decode() does not exist using PHP4


Christophe
geotree.geonames.org
geotree.geonames.org/geotree.html
[WWW]
nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

Thanks. But with reverse geocoding I have a lat and lng. Where do I put this information in the url and how do I refer to the city, province, country and countrycode?

Nico.
geotree


[Avatar]
Joined: 23/07/2007 18:28:40
Messages: 138
Location: France
Offline

Use lat= and long= parameters
Code:
 $url = "http://ws.geonames.org/findNearbyPlaceNameJSON?lat=47.3&lng=9"
 $json = file_get_contents($url);
 $data = json_decode($json, true);
 foreach ($data["geonames"] as $key => $val) {
 	echo $val["name"]." ".$val["countryName"]." ".$val["countryCode"]."<br />";
 }

Christophe
geotree.geonames.org
geotree.geonames.org/geotree.html
[WWW]
nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

When I test this code I get the following error???

Parse error: syntax error, unexpected T_VARIABLE in .... on line 2

geotree


[Avatar]
Joined: 23/07/2007 18:28:40
Messages: 138
Location: France
Offline

Just add a missing ; to the first line.

Christophe
geotree.geonames.org
geotree.geonames.org/geotree.html
[WWW]
kumarpavan48



Joined: 07/02/2012 15:11:55
Messages: 2
Offline

Can u Help me I have List of Latitude, Longitude, in mysql database .....Let me know how can i get the mysql data as output by getting in a map.....

$url = "http://ws.geonames.org/findNearbyPlaceNameJSON?lat=17.24&lng=78.18";
$json = file_get_contents($url);
$data = json_decode($json, true);
foreach ($data["geonames"] as $key => $val) {
echo $val["name"]." ".$val["countryName"]." ".$val["countryCode"]."<br />";
}

My Goal was to Show Address (Locaton,counrty,code) on map By using My Mysql DAta base any one plzz help me this is my acdemic project time only two days
kumarpavan48



Joined: 07/02/2012 15:11:55
Messages: 2
Offline

canu plz help in reverse geocoding!!!
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team