Created
November 14, 2016 16:09
-
-
Save here-devblog-gists/cca42e770d80eb3ceae56970d3a46acb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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