GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
how to use Find nearby place name / reverse geocoding?  XML
Forum Index -> General
Author Message
missokhay



Joined: 20/08/2007 16:15:56
Messages: 5
Offline

i want to use this web service (Find nearby place name / reverse geocoding)
to display adress information in the infowindow of a marker located with its lat/lng(i'm using google map api). i've seen that i must send a HTTP request to get an XML file but i have no idea how to integrate it to my site: http://missokhay.alwaysdata.net/animation.htm
any help is welcome
marc



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

You cannot use our XML service from your javascript code, you will have to use XML via you server. This restriction comes from a browser 'security' feature. The browser does not allow XML calls to third party servers.
You can overcome this problem and use the JSON version of the same service.

You can look at our example for the search service to get an idea of JSON programming :
http://www.geonames.org/maps/json-googlemaps-example.html

Hope this helps to get you started

Marc

[WWW]
missokhay



Joined: 20/08/2007 16:15:56
Messages: 5
Offline

thanks a lot for reply!
what do you mean by third part server?
i'll try to use the example you mentioned but i still have question why JSON version is allowed? i'm really newbie and want to understand how things are running!!
marc



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

Lets say a user comes to your site www.yoursite.com than the browser of this user will refuse to load xml data from the server geonames.org. There is no such security restriction for JSON data.


Marc

[WWW]
missokhay



Joined: 20/08/2007 16:15:56
Messages: 5
Offline

ok! thanks!
missokhay



Joined: 20/08/2007 16:15:56
Messages: 5
Offline

i'm just wondering: if i use php to parse the XML file; my browser won't be able to detect that i'm iloading an XML file as php script is executed in the server side. what do you think?
marc



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

Sure, parsing xml on the server will work. A lot of people to this.

Marc

[WWW]
missokhay



Joined: 20/08/2007 16:15:56
Messages: 5
Offline

i'm really admiring: you don't hesitate to reply any question. thanks a lot!!!
the code of the example is very useful and well commented.
can you tell me about the jData parameter how the function getLocation got it and what is the callback?
marc



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

thanks missokhay.

missokhay wrote:

can you tell me about the jData parameter how the function getLocation got it and what is the callback?
 

the jData is the result GeoNames is returning. When you add the 'callback' parameter to the web service call GeoNames will return the result in a way that the function you pass as 'callback' will automatically be called and you can process the data in your own function. Cool, isn't it?

Cheers

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team