js_compilation/gmaps_google.js in gmaps4rails-2.1.1 vs js_compilation/gmaps_google.js in gmaps4rails-2.1.2
- old
+ new
@@ -92,16 +92,16 @@
})();
}).call(this);
(function() {
this.Gmaps.Objects.Builders = function(builderClass, objectClass, primitivesProvider) {
- objectClass.PRIMITIVES = primitivesProvider;
- builderClass.OBJECT = objectClass;
- builderClass.PRIMITIVES = primitivesProvider;
return {
build: function(args, provider_options, internal_options) {
var builder;
+ objectClass.PRIMITIVES = primitivesProvider;
+ builderClass.OBJECT = objectClass;
+ builderClass.PRIMITIVES = primitivesProvider;
builder = new builderClass(args, provider_options, internal_options);
return builder.build();
}
};
};
@@ -114,10 +114,11 @@
if (options == null) {
options = {};
}
this.setPrimitives(options);
this.setOptions(options);
+ this._cacheAllBuilders();
this.resetBounds();
}
Handler.prototype.buildMap = function(options, onMapLoad) {
var _this = this;
@@ -232,10 +233,18 @@
resource = this._builder(resource_name).build(resource_data, provider_options);
resource.setMap(this.getMap());
return resource;
};
+ Handler.prototype._cacheAllBuilders = function() {
+ var that;
+ that = this;
+ return _.each(['Bound', 'Circle', 'Clusterer', 'Kml', 'Map', 'Marker', 'Polygon', 'Polyline'], function(kind) {
+ return that._builder(kind);
+ });
+ };
+
Handler.prototype._clusterize = function() {
return _.isObject(this.marker_options.clusterer);
};
Handler.prototype._createClusterer = function() {
@@ -243,18 +252,18 @@
map: this.getMap()
}, this.marker_options.clusterer);
};
Handler.prototype._default_marker_options = function() {
- return {
+ return _.clone({
singleInfowindow: true,
- maxRandomDistance: 100,
+ maxRandomDistance: 0,
clusterer: {
maxZoom: 5,
gridSize: 50
}
- };
+ });
};
Handler.prototype._builder = function(name) {
var _name;
name = this._capitalize(name);
@@ -264,11 +273,11 @@
return this["__builder" + name];
};
Handler.prototype._default_models = function() {
var models;
- models = this._rootModule().Objects;
+ models = _.clone(this._rootModule().Objects);
if (this._clusterize()) {
return models;
} else {
models.Clusterer = Gmaps.Objects.NullClusterer;
return models;
@@ -278,11 +287,11 @@
Handler.prototype._capitalize = function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
};
Handler.prototype._default_builders = function() {
- return this._rootModule().Builders;
+ return _.clone(this._rootModule().Builders);
};
Handler.prototype._rootModule = function() {
if (this.__rootModule == null) {
this.__rootModule = Gmaps[this.type];
@@ -955,10 +964,14 @@
return new factory.latLng(position[0], position[1]);
} else {
if (_.isNumber(position.lat) && _.isNumber(position.lng)) {
return new factory.latLng(position.lat, position.lng);
} else {
- return position;
+ if (_.isFunction(position.getServiceObject)) {
+ return position.getServiceObject().getPosition();
+ } else {
+ return position;
+ }
}
}
}
};
return factory;