diff --git a/lib/geocoder/locationiqgeocoder.js b/lib/geocoder/locationiqgeocoder.js index dbe77f0..56ddb1e 100644 --- a/lib/geocoder/locationiqgeocoder.js +++ b/lib/geocoder/locationiqgeocoder.js @@ -119,12 +119,15 @@ LocationIQGeocoder.prototype._reverse = function(query, callback) { LocationIQGeocoder.prototype._formatResult = function(result) { // transform lat and lon to real floats var transformedResult = { - 'latitude' : result.lat ? parseFloat(result.lat) : undefined, - 'longitude' : result.lon ? parseFloat(result.lon) : undefined + latitude : result.lat ? parseFloat(result.lat) : undefined, + longitude : result.lon ? parseFloat(result.lon) : undefined, }; + if (result.display_name) { + transformedResult.formattedAddress = result.display_name; + } + if (result.address) { - transformedResult.country = result.address.country; transformedResult.country = result.address.country; transformedResult.city = result.address.city || result.address.town || result.address.village || result.address.hamlet; transformedResult.state = result.address.state; @@ -132,12 +135,15 @@ LocationIQGeocoder.prototype._formatResult = function(result) { transformedResult.streetName = result.address.road || result.address.cycleway; transformedResult.streetNumber = result.address.house_number; + if (transformedResult.county) { + transformedResult.county = result.address.county; + } + // make sure countrycode is always uppercase to keep node-geocoder api formats var countryCode = result.address.country_code; if (countryCode) { countryCode = countryCode.toUpperCase(); } - transformedResult.countryCode = countryCode; } return transformedResult;