I’m baffled! I’m coding in HTML5 and getting back the geo coordinates with no problems; I set them as cookies for future reference, then pass them to a reverse geolocation server using $.getJSON in jQuery 1.5.1. I have to parse through the results, but I manage to get the user’s US state location (which is my goal) in Firefox, but not in IE.
The JSON appears to be well-formed, and looks like this:
{"place_id":"3065317","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"356821721","lat":"32.9029017","lon":"-96.5636022","display_name":"Church of the Nazarene, Main Street, Dallas, Texas, 75088, United States of America","address":{"place_of_worship":"Church of the Nazarene","road":"Main Street","city":"Dallas","county":"Dallas","state":"Texas","postcode":"75088","country":"United States of America","country_code":"us"}}
Here’s how I’m parsing it (not elegant I know, and I wouldn’t mind suggestions on improvements!):
$.getJSON('http://nominatim.openstreetmap.org/reverse?format=json&lat=' + Get_Cookie('Latitude') +'&lon=' + Get_Cookie('Longitude') + '&zoom=18&addressdetails=1',
function(data) {
var st;
$.each(data, function(key,val) {
if (key == 'address') {
$.each(val, function(subkey,subval) {
if (subkey == 'state') {
st = subval;
};
});
}
});
Set_Cookie('state',st,true,'/');
});
Would appreciate any help on this… TIA!