diff --git a/geocoder/utils/formatters.js b/geocoder/utils/formatters.js index b10e272e..f398e6a8 100644 --- a/geocoder/utils/formatters.js +++ b/geocoder/utils/formatters.js @@ -64,21 +64,29 @@ module.exports = (config, _) => { lang = lang || config.default_lang; - const items = _.get(data,'body.Response.View[0].Result'); + //const items = _.get(data,'body.Response.View[0].Result'); + const items = _.get(data,'items'); - return _.compact(_.map(items, (item)=> { + console.log('HERE RETURN',JSON.stringify(items,null,4)) - let lat = _.get(item,"Location.DisplayPosition.Latitude"), + return _.compact(_.map(items, item => { + +/* let lat = _.get(item,"Location.DisplayPosition.Latitude"), lon = _.get(item,"Location.DisplayPosition.Longitude"), a = _.get(item,"Location.Address"), - text = _.compact([a.Street, a.HouseNumber, a.City]).join(', '); + text = _.compact([a.Street, a.HouseNumber, a.City]).join(', ');*/ + let lat = _.get(item,"position.lat") + , lon = _.get(item,"position.lng") + , text = _.get(item,"address.label"); +console.log(item.id,lat,lon,text) if (lat && lon) { + return createHit({ - id: _.get(item,'Location.LocationId'), - text: text, - lat: lat, - lon: lon, + id: item.id, + text, + lat, + lon, source: 'here', layer: config.endpoints.here.layer }); diff --git a/geocoder/utils/services.js b/geocoder/utils/services.js index ed779b78..36e379bb 100644 --- a/geocoder/utils/services.js +++ b/geocoder/utils/services.js @@ -26,7 +26,7 @@ const heremap = { +`&apiKey=${api_key}` +`&q=${text}` //+`&lang=${lang}` - +'&result_types=address,place' + //+'&result_types=address,place' +`&in=bbox:${bbox}` //+`&in=countryCode:${country}` +`&limit=${limit}`; @@ -47,8 +47,7 @@ const heremap = { res.on('end', () => { try { const data = JSON.parse(str); - console.log('RETURN',JSON.stringify(data,null,4)) - resolve({}); + resolve(data); } catch(err) { console.error(`Error "${err}" to connect endpoint ${endpoint.hostname}${endpoint.path}`);