我試圖修改此示例 http://storelocator.googlecode.com/git/examples/panel.html谷歌地圖商店定位器修改硬編碼的初始化動態
的JavaScript代碼是在這裏: https://gist.github.com/2725336
我遇到了正在改變這種困難的方面:
MedicareDataSource.prototype.FEATURES_ = new storeLocator.FeatureSet(
new storeLocator.Feature('Wheelchair-YES', 'Wheelchair access'),
new storeLocator.Feature('Audio-YES', 'Audio')
);
從函數創建的FeatureSet,因此,例如我有這種功能,它解析JSON對象
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);
};
所以後來改第一代碼片段爲類似
WPmmDataSource.prototype.FEATURES_ = this.setFeatures_(wpmm_features);
返回一個錯誤:
Uncaught TypeError: Object [object Window] has no method 'setFeatures_'
我在這裏放一個這樣的演示:http://demo.wpconsult.net/你可以看到在控制檯 – paul