Skip to content

Instantly share code, notes, and snippets.

@here-devblog-gists
Created November 14, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save here-devblog-gists/cca42e770d80eb3ceae56970d3a46acb to your computer and use it in GitHub Desktop.
Save here-devblog-gists/cca42e770d80eb3ceae56970d3a46acb to your computer and use it in GitHub Desktop.
HEREPlaces.prototype.getPlaces = function(query, onSuccessCallback) {
var onSuccess,
onError;
onSuccess = function(data) {
if (data.results && data.results.items) {
var places = data.results.items.map(function(place) {
place.coordinates = { lat: place.position[0], lng: place.position[1] };
return place;
});
onSuccessCallback(data.results.items);
} else {
onError(data);
}
};
onError = function(error) {
console.error('Error happened when fetching places!', error);
};
this.placeSearch.request(query, {}, onSuccess, onError);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment