I’m trying to modify this example
http://storelocator.googlecode.com/git/examples/panel.html
the javascript code is here:
https://gist.github.com/2725336
the aspect I’m having difficulties with is changing this:
MedicareDataSource.prototype.FEATURES_ = new storeLocator.FeatureSet(
new storeLocator.Feature('Wheelchair-YES', 'Wheelchair access'),
new storeLocator.Feature('Audio-YES', 'Audio')
);
to create the FeatureSet from a function, so for example I have this function which parses a JSON object
WPmmDataSource.prototype.setFeatures_ = function(json) {
var features = [];
// convert features JSON to js object
var rows = jQuery.parseJSON(json);
// iterate through features collection
jQuery.each(rows, function(i, row){
var feature = new storeLocator.Feature(row.slug + '-YES', row.name)
features.push(feature);
});
return new storeLocator.FeatureSet(features);
};
so then change the first code snippet to something like
WPmmDataSource.prototype.FEATURES_ = this.setFeatures_(wpmm_features);
which returns an error:
Uncaught TypeError: Object [object Window] has no method 'setFeatures_'
I think you just have to make some changes to the
WPmmDataSource.prototypeand yoursetFeatures_method:And with this, you don’t have to do the assignment by returning a value from
setFeatures_; it has direct access to theFEATURES_member. So the line:is no longer necessary. This also means that later, when you have created an instance of
WPmmDataSource, your code can work like this:I’m not exactly sure what you are trying to achieve, but I believe this will get you over the hurdle of your current stall. I hope this gets you moving forward –