js_compilation/gmaps_google.js in gmaps4rails-2.0.3 vs js_compilation/gmaps_google.js in gmaps4rails-2.0.4
- old
+ new
@@ -122,11 +122,11 @@
Handler.prototype.buildMap = function(options, onMapLoad) {
var _this = this;
if (onMapLoad == null) {
onMapLoad = function() {};
}
- return this.map = this._map_builder().build(options, function() {
+ return this.map = this._builder('Map').build(options, function() {
_this._createClusterer();
return onMapLoad();
});
};
@@ -137,11 +137,11 @@
});
};
Handler.prototype.addMarker = function(marker_data, provider_options) {
var marker;
- marker = this._marker_builder().build(marker_data, provider_options, this.marker_options);
+ marker = this._builder('Marker').build(marker_data, provider_options, this.marker_options);
marker.setMap(this.getMap());
this.clusterer.addMarker(marker);
return marker;
};
@@ -187,10 +187,22 @@
Handler.prototype.addKml = function(kml_data, provider_options) {
return this._addResource('kml', kml_data, provider_options);
};
+ Handler.prototype.removeMarkers = function(gem_markers) {
+ var _this = this;
+ return _.map(gem_markers, function(gem_marker) {
+ return _this.removeMarker(gem_marker);
+ });
+ };
+
+ Handler.prototype.removeMarker = function(gem_marker) {
+ gem_marker.clear();
+ return this.clusterer.removeMarker(gem_marker);
+ };
+
Handler.prototype.fitMapToBounds = function() {
return this.map.fitToBounds(this.bounds.getServiceObject());
};
Handler.prototype.getMap = function() {
@@ -202,11 +214,11 @@
this.builders = _.extend(this._default_builders(), options.builders);
return this.models = _.extend(this._default_models(), options.models);
};
Handler.prototype.resetBounds = function() {
- return this.bounds = this._bound_builder().build();
+ return this.bounds = this._builder('Bound').build();
};
Handler.prototype.setPrimitives = function(options) {
return this.primitives = options.primitives === void 0 ? this._rootModule().Primitives() : _.isFunction(options.primitives) ? options.primitives() : options.primitives;
};
@@ -215,21 +227,21 @@
return this.builders.Marker.CURRENT_INFOWINDOW;
};
Handler.prototype._addResource = function(resource_name, resource_data, provider_options) {
var resource;
- resource = this["_" + resource_name + "_builder"]().build(resource_data, provider_options);
+ resource = this._builder(resource_name).build(resource_data, provider_options);
resource.setMap(this.getMap());
return resource;
};
Handler.prototype._clusterize = function() {
return _.isObject(this.marker_options.clusterer);
};
Handler.prototype._createClusterer = function() {
- return this.clusterer = this._clusterer_builder().build({
+ return this.clusterer = this._builder('Clusterer').build({
map: this.getMap()
}, this.marker_options.clusterer);
};
Handler.prototype._default_marker_options = function() {
@@ -241,44 +253,13 @@
gridSize: 50
}
};
};
- Handler.prototype._bound_builder = function() {
- return this._builder('Bound');
- };
-
- Handler.prototype._clusterer_builder = function() {
- return this._builder('Clusterer');
- };
-
- Handler.prototype._marker_builder = function() {
- return this._builder('Marker');
- };
-
- Handler.prototype._map_builder = function() {
- return this._builder('Map');
- };
-
- Handler.prototype._kml_builder = function() {
- return this._builder('Kml');
- };
-
- Handler.prototype._circle_builder = function() {
- return this._builder('Circle');
- };
-
- Handler.prototype._polyline_builder = function() {
- return this._builder('Polyline');
- };
-
- Handler.prototype._polygon_builder = function() {
- return this._builder('Polygon');
- };
-
Handler.prototype._builder = function(name) {
var _name;
+ name = this._capitalize(name);
if (this[_name = "__builder" + name] == null) {
this[_name] = Gmaps.Objects.Builders(this.builders[name], this.models[name], this.primitives);
}
return this["__builder" + name];
};
@@ -292,10 +273,14 @@
models.Clusterer = Gmaps.Objects.NullClusterer;
return models;
}
};
+ Handler.prototype._capitalize = function(string) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+ };
+
Handler.prototype._default_builders = function() {
return this._rootModule().Builders;
};
Handler.prototype._rootModule = function() {
@@ -318,10 +303,12 @@
NullClusterer.prototype.addMarker = function() {};
NullClusterer.prototype.clear = function() {};
+ NullClusterer.prototype.removeMarker = function() {};
+
return NullClusterer;
})();
}).call(this);
@@ -332,21 +319,20 @@
},
setMap: function(map) {
return this.getServiceObject().setMap(map);
},
clear: function() {
- this.serviceObject.setMap(null);
- return this.serviceObject = null;
+ return this.getServiceObject().setMap(null);
},
show: function() {
- return this.serviceObject.setVisible(true);
+ return this.getServiceObject().setVisible(true);
},
hide: function() {
- return this.serviceObject.setVisible(false);
+ return this.getServiceObject().setVisible(false);
},
isVisible: function() {
- return this.serviceObject.getVisible();
+ return this.getServiceObject().getVisible();
},
primitives: function() {
return this.constructor.PRIMITIVES;
}
};
@@ -747,32 +733,35 @@
})(Gmaps.Base);
}).call(this);
(function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
-
this.Gmaps.Google.Objects.Clusterer = (function() {
function Clusterer(serviceObject) {
this.serviceObject = serviceObject;
- this.clear = __bind(this.clear, this);
- this.addMarker = __bind(this.addMarker, this);
- this.addMarkers = __bind(this.addMarkers, this);
}
Clusterer.prototype.addMarkers = function(markers) {
var _this = this;
return _.each(markers, function(marker) {
return _this.addMarker(marker);
});
};
Clusterer.prototype.addMarker = function(marker) {
- return this.serviceObject.addMarker(marker.serviceObject);
+ return this.getServiceObject().addMarker(marker.getServiceObject());
};
Clusterer.prototype.clear = function() {
- return this.serviceObject.clearMarkers();
+ return this.getServiceObject().clearMarkers();
+ };
+
+ Clusterer.prototype.removeMarker = function(marker) {
+ return this.getServiceObject().removeMarker(marker.getServiceObject());
+ };
+
+ Clusterer.prototype.getServiceObject = function() {
+ return this.serviceObject;
};
return Clusterer;
})();