Created
February 28, 2016 04:28
-
-
Save chasestarr/905c8fe10825ab2c45a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var searchYelp = function(params, callback){ | |
yelp.search(params, function(e,res){ | |
// console.log(res); | |
if(e) return console.log(e); | |
var center = [res.region.center.latitude, res.region.center.longitude]; | |
//Map api response to format readable by mapbox | |
var businessData = res.businesses.map(function(element){ | |
var coordObj = element.location.coordinate; | |
var output = readDB(element.id, function(tableStatus){ | |
var obj = { | |
type: "Feature", | |
geometry:{ | |
type: "Point", | |
coordinates: [coordObj.longitude,coordObj.latitude] | |
}, | |
properties:{ | |
title: element.name, | |
url: element.url, | |
address: element.location.address[0], | |
rating: starRating(element.rating), | |
host: tableStatus, | |
id: element.id, | |
"marker-color": "#fc4353", | |
"marker-size": "small" | |
} | |
}; | |
return obj; | |
}); | |
return output; | |
}); | |
//package data to not repeat center obj | |
var geoObj = { | |
center: center, | |
geoJSON: businessData | |
} | |
callback(geoObj); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment