Adding a bit of flexibility to extend and applyDefaults. First argument can now be undefined. r=pspencer,elemoine (closes #1564)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7311 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -550,9 +550,9 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
if (inlineStyleNode) {
|
||||
var inlineStyle= this.parseStyle(inlineStyleNode);
|
||||
if (inlineStyle) {
|
||||
feature.style = OpenLayers.Util.extend({},
|
||||
feature.style);
|
||||
OpenLayers.Util.extend(feature.style, inlineStyle);
|
||||
feature.style = OpenLayers.Util.extend(
|
||||
feature.style, inlineStyle
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,13 +64,9 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var newArguments = [];
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (params) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
this.DEFAULT_PARAMS
|
||||
);
|
||||
}
|
||||
this.params = OpenLayers.Util.applyDefaults(
|
||||
this.params, this.DEFAULT_PARAMS
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,12 +42,9 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
this.DEFAULT_PARAMS
|
||||
);
|
||||
}
|
||||
this.params = OpenLayers.Util.applyDefaults(
|
||||
this.params, this.DEFAULT_PARAMS
|
||||
);
|
||||
|
||||
// unless explicitly set in options, if the layer is transparent,
|
||||
// it will be an overlay
|
||||
|
||||
@@ -138,11 +138,10 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
this.options.geometry_column = "the_geom";
|
||||
}
|
||||
|
||||
this.params = params;
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
this.params = OpenLayers.Util.applyDefaults(
|
||||
params,
|
||||
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||
);
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
|
||||
@@ -54,13 +54,9 @@ OpenLayers.Layer.WorldWind = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var newArguments = [];
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (params) {
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.params,
|
||||
this.DEFAULT_PARAMS
|
||||
);
|
||||
}
|
||||
this.params = OpenLayers.Util.applyDefaults(
|
||||
this.params, this.DEFAULT_PARAMS
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Method: addTile
|
||||
|
||||
@@ -1335,11 +1335,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
* false.
|
||||
*/
|
||||
pan: function(dx, dy, options) {
|
||||
// this should be pushed to applyDefaults and extend
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
OpenLayers.Util.applyDefaults(options, {
|
||||
options = OpenLayers.Util.applyDefaults(options, {
|
||||
animate: true,
|
||||
dragging: false
|
||||
});
|
||||
|
||||
@@ -49,7 +49,8 @@ if ($ == null) {
|
||||
* {Object} The destination object.
|
||||
*/
|
||||
OpenLayers.Util.extend = function(destination, source) {
|
||||
if(destination && source) {
|
||||
destination = destination || {};
|
||||
if(source) {
|
||||
for(var property in source) {
|
||||
var value = source[property];
|
||||
if(value !== undefined) {
|
||||
@@ -522,7 +523,7 @@ OpenLayers.Util.upperCaseObject = function (object) {
|
||||
* in place and returned by this function.
|
||||
*/
|
||||
OpenLayers.Util.applyDefaults = function (to, from) {
|
||||
|
||||
to = to || {};
|
||||
/*
|
||||
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
|
||||
* prototype object" when calling hawOwnProperty if the source object is an
|
||||
|
||||
Reference in New Issue
Block a user