Tôi đang cố gắng để thay đổi ví dụ này http://storelocator.googlecode.com/git/examples/panel.htmlgoogle lưu trữ bản đồ định vị sửa đổi khởi hardcoded để động
mã javascript là ở đây: https://gist.github.com/2725336
khía cạnh Tôi đang gặp khó khăn với thay đổi này:
MedicareDataSource.prototype.FEATURES_ = new storeLocator.FeatureSet(
new storeLocator.Feature('Wheelchair-YES', 'Wheelchair access'),
new storeLocator.Feature('Audio-YES', 'Audio')
);
để tạo ra các featureset từ một chức năng, ví dụ như vậy tôi có chức năng này mà phân tích một đối tượng 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);
};
như vậy thì thay đổi đoạn mã đầu tiên để một cái gì đó giống như
WPmmDataSource.prototype.FEATURES_ = this.setFeatures_(wpmm_features);
mà trả về một lỗi:
Uncaught TypeError: Object [object Window] has no method 'setFeatures_'
Tôi đặt bản trình diễn này tại đây: http://demo.wpconsult.net/ bạn có thể thấy thông báo lỗi trong bảng điều khiển – paul