GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Multiple queries with one coordinate  XML
Forum Index -> General
Author Message
SURF-IT



Joined: 18/07/2008 07:52:34
Messages: 3
Offline

I would like to click once on a map and determine if that location is an intersection (from the JSON data about distance) and the nearby streets. What is the best way to do this? I have some code that isn't working right now, but even if it's just a bug I am thinking there might be a better way to do this.

Code:
GEvent.addListener(polyline, 'click', function(latlng) {
 				var selectedWebService = getService();
 				var script = document.createElement('script');
                                 document.body.appendChild(script);
                                 script.src = 'http://ws.geonames.org/' + selectedWebService + 'JSON?lat=' + latlng.lat() + '&lng=' + latlng.lng() + '&callback=loadJSON';
 				var script2 = document.createElement('script2');
 				document.body.appendChild(script2);
 				script2.src = 'http://ws.geonames.org/findNearestIntersectionJSON?lat=' + latlng.lat() + '&lng=' + latlng.lng() + '&callback=isIntersection';
 		});


Sort of along those lines, is the only way to access the JSON or XML data from the query with a callback function? Or is there some way to return it simply to a variable? For example, if I do 'http://ws.geonames.org/findNearestIntersectionJSON?lat=36&lng=-122' and only want to check the distance attribute--do I still have to use a callback function?

Thanks!!
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team