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!!