Skip to content

Instantly share code, notes, and snippets.

@cthrax
Created November 20, 2014 00:44
Show Gist options
  • Save cthrax/7d392e8487f8f55dbde7 to your computer and use it in GitHub Desktop.
Save cthrax/7d392e8487f8f55dbde7 to your computer and use it in GitHub Desktop.
var LocationQuery = function() {
this.projects = null;
this.parameters = null;
this.labels = null;
this.gpsBounds = null;
this.pageObject = null;
this.query = {};
};
LocationQuery.prototype._addToQuery = function(prop) {
if (!!this[prop]) {
this.query[prop] = this[prop];
}
};
LocationQuery.prototype.toParam = function() {
var props = ["projects", "parameters", "labels", "gpsBounds", "locationIds", "pageObject"];
props.map(this._addToQuery, this);
var val = JSON.stringify(this.query);
return {
q: val
};
};
var LocationDataQuery = function() {
this.resolution = null;
this.timeslice = null;
};
// Inherit from LocationQuery
LocationDataQuery.prototype = Object.create(new LocationQuery());
LocationDataQuery.prototype.toParam = function() {
// Add locationSpecific properties to query
var locationDataProps = ["resolution", "timeslice"];
locationDataProps.map(this._addToQuery, this);
// Add super values and return result
return LocationQuery.prototype.toParam.call(this);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment