Merge branch 'master' of github.com:openlayers/openlayers

This commit is contained in:
ahocevar
2012-03-04 11:25:10 +01:00
36 changed files with 350 additions and 400 deletions
-2
View File
@@ -91,13 +91,11 @@ OpenLayers.Util.extend = function(destination, source) {
destination = destination || {};
if (source) {
for (var property in source) {
if (Object.prototype.hasOwnProperty.call(source, property)) {
var value = source[property];
if (value !== undefined) {
destination[property] = value;
}
}
}
/**
* IE doesn't include the toString property when iterating over an object's
-8
View File
@@ -258,11 +258,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
activate: function () {
if (!this.active) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].activate();
}
}
}
return OpenLayers.Control.prototype.activate.apply(
this, arguments
);
@@ -278,11 +276,9 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
deactivate: function () {
if (this.active) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].deactivate();
}
}
}
return OpenLayers.Control.prototype.deactivate.apply(
this, arguments
);
@@ -564,10 +560,8 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
unselectAll: function() {
// we'll want an option to supress notification here
for(var fid in this.features) {
if (this.features.hasOwnProperty(fid)) {
this.unselect(this.features[fid]);
}
}
},
/**
@@ -579,10 +573,8 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
*/
setMap: function(map) {
for(var i in this.handlers) {
if (this.handlers.hasOwnProperty(i)) {
this.handlers[i].setMap(map);
}
}
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
+2 -2
View File
@@ -231,8 +231,8 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
* mouseposition. feature - {<OpenLayers.Feature.Vector>} The sketch feature.
*/
measureImmediate : function(point, feature, drawing) {
if (drawing && this.delayedTrigger === null &&
!this.handler.freehandMode(this.handler.evt)) {
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
this.cancelDelay();
this.measure(feature.geometry, "measurepartial");
}
},
@@ -193,10 +193,8 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.next.destroy();
this.deactivate();
for(var prop in this) {
if (this.hasOwnProperty(prop)) {
this[prop] = null;
}
}
},
/**
@@ -336,7 +334,6 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
setListeners: function() {
this.listeners = {};
for(var type in this.registry) {
if (this.registry.hasOwnProperty(type)) {
this.listeners[type] = OpenLayers.Function.bind(function() {
if(!this.restoring) {
var state = this.registry[type].apply(this, arguments);
@@ -357,7 +354,6 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
return true;
}, this);
}
}
},
/**
@@ -375,10 +371,8 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.setListeners();
}
for(var type in this.listeners) {
if (this.listeners.hasOwnProperty(type)) {
this.map.events.register(type, this, this.listeners[type]);
}
}
activated = true;
if(this.previousStack.length == 0) {
this.initStack();
@@ -411,12 +405,10 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
if(this.map) {
if(OpenLayers.Control.prototype.deactivate.apply(this)) {
for(var type in this.listeners) {
if (this.listeners.hasOwnProperty(type)) {
this.map.events.unregister(
type, this, this.listeners[type]
);
}
}
if(this.clearOnDeactivate) {
this.clear();
}
+4 -3
View File
@@ -94,12 +94,13 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
* APIMethod: destroy
*/
destroy: function() {
if (this.element.parentNode == this.div) {
if (this.element && this.element.parentNode == this.div) {
this.div.removeChild(this.element);
}
this.element = null;
}
if (this.map) {
this.map.events.unregister('moveend', this, this.updateLink);
}
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
+2 -7
View File
@@ -168,17 +168,12 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
* Take care of things that are not handled in superclass.
*/
destroy: function() {
var key;
for (key in this.layerCache) {
if (this.layerCache.hasOwnProperty(key)) {
for (var key in this.layerCache) {
delete this.layerCache[key];
}
}
for (key in this.wfsCache) {
if (this.wfsCache.hasOwnProperty(key)) {
for (var key in this.wfsCache) {
delete this.wfsCache[key];
}
}
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
@@ -456,14 +456,12 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
}
var layers;
for (var url in services) {
if (services.hasOwnProperty(url)) {
layers = services[url];
var wmsOptions = this.buildWMSOptions(url, layers,
clickPosition, layers[0].params.FORMAT);
OpenLayers.Request.GET(wmsOptions);
}
}
}
},
/**
-2
View File
@@ -564,7 +564,6 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("feature:_geometry", feature.geometry, node);
}
for(var name in feature.attributes) {
if (feature.attributes.hasOwnProperty(name)) {
var value = feature.attributes[name];
if(value != null) {
this.writeNode(
@@ -573,7 +572,6 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
);
}
}
}
return node;
},
"_geometry": function(geometry) {
-2
View File
@@ -325,7 +325,6 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
featureNode.appendChild(linkNode);
}
for(var attr in feature.attributes) {
if (feature.attributes.hasOwnProperty(attr)) {
if (attr == "link" || attr == "title" || attr == "description") { continue; }
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
@@ -336,7 +335,6 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
attrContainer.appendChild(attrText);
featureNode.appendChild(attrContainer);
}
}
featureNode.appendChild(geometryNode);
return featureNode;
},
-6
View File
@@ -140,7 +140,6 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
feat_list[i] = feat;
}
for (var node_id in nodes) {
if (nodes.hasOwnProperty(node_id)) {
var node = nodes[node_id];
if (!node.used || this.checkTags) {
var tags = null;
@@ -169,7 +168,6 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
// Memory cleanup
node.node = null;
}
}
return feat_list;
},
@@ -275,14 +273,12 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
}
if (this.checkTags) {
for(var key in way.tags) {
if (way.tags.hasOwnProperty(key)) {
if (this.areaTags[key]) {
poly_tags = true;
break;
}
}
}
}
return poly_shaped && (this.checkTags ? poly_tags : true);
},
@@ -434,13 +430,11 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
*/
serializeTags: function(feature, node) {
for (var key in feature.attributes) {
if (feature.attributes.hasOwnProperty(key)) {
var tag = this.createElementNS(null, "tag");
tag.setAttribute("k", key);
tag.setAttribute("v", feature.attributes[key]);
node.appendChild(tag);
}
}
},
/**
+1 -9
View File
@@ -541,13 +541,11 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
getCssProperty: function(sym) {
var css = null;
for(var prop in this.cssMap) {
if (this.cssMap.hasOwnProperty(prop)) {
if(this.cssMap[prop] == sym) {
css = prop;
break;
}
}
}
return css;
},
@@ -567,14 +565,12 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
getGraphicFormat: function(href) {
var format, regex;
for(var key in this.graphicFormats) {
if (this.graphicFormats.hasOwnProperty(key)) {
if(this.graphicFormats[key].test(href)) {
format = key;
break;
}
}
}
return format || this.defaultGraphicFormat;
return format || this.defautlGraphicFormat;
},
/**
@@ -680,11 +676,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
}
} else {
for(var name in sld.namedLayers) {
if (sld.namedLayers.hasOwnProperty(name)) {
this.writeNode("NamedLayer", sld.namedLayers[name], root);
}
}
}
return root;
},
"Name": function(name) {
@@ -775,14 +769,12 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
ruleMap[zIndex].symbolizers.push(symbolizer.clone());
}
for (zIndex in ruleMap) {
if (ruleMap.hasOwnProperty(zIndex)) {
if (!(zIndex in rulesByZ)) {
zValues.push(zIndex);
rulesByZ[zIndex] = [];
}
rulesByZ[zIndex].push(ruleMap[zIndex]);
}
}
} else {
// no symbolizers in rule
rulesByZ[0].push(rule.clone());
@@ -128,14 +128,12 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class(
var options = symbolizer.vendorOptions;
if (options) {
for (var key in symbolizer.vendorOptions) {
if (symbolizer.vendorOptions.hasOwnProperty(key)) {
this.writeNode("VendorOption", {
name: key,
value: symbolizer.vendorOptions[key]
}, node);
}
}
}
return node;
},
@@ -210,15 +210,11 @@ OpenLayers.Format.SOSGetObservation = OpenLayers.Class(OpenLayers.Format.XML, {
this.writeNode("eventTime", options, node);
}
for (var procedure in options.procedures) {
if (options.procedures.hasOwnProperty(procedure)) {
this.writeNode("procedure", options.procedures[procedure], node);
}
}
for (var observedProperty in options.observedProperties) {
if (options.observedProperties.hasOwnProperty(observedProperty)) {
this.writeNode("observedProperty", options.observedProperties[observedProperty], node);
}
}
if (options.foi) {
this.writeNode("featureOfInterest", options.foi, node);
}
-4
View File
@@ -104,7 +104,6 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
var featureContainer = this.createElementNS(this.featureNS, "feature:" + this.featureName);
featureContainer.appendChild(geomContainer);
for(var attr in feature.attributes) {
if (feature.attributes.hasOwnProperty(attr)) {
var attrText = this.createTextNode(feature.attributes[attr]);
var nodename = attr;
if (attr.search(":") != -1) {
@@ -114,7 +113,6 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
attrContainer.appendChild(attrText);
featureContainer.appendChild(attrContainer);
}
}
return featureContainer;
},
@@ -168,7 +166,6 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
// add in attributes
for(var propName in feature.attributes) {
if (feature.attributes.hasOwnProperty(propName)) {
propertyNode = this.createElementNS(this.wfsns, 'wfs:Property');
nameNode = this.createElementNS(this.wfsns, 'wfs:Name');
nameNode.appendChild(this.createTextNode(propName));
@@ -178,7 +175,6 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, {
propertyNode.appendChild(valueNode);
updateNode.appendChild(propertyNode);
}
}
var filterNode = this.createElementNS(this.ogcns, 'ogc:Filter');
-4
View File
@@ -332,7 +332,6 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
// add in attributes
for(var key in feature.attributes) {
if (feature.attributes.hasOwnProperty(key)) {
if(feature.attributes[key] !== undefined &&
(!modified || !modified.attributes ||
(modified.attributes && modified.attributes[key] !== undefined))) {
@@ -341,7 +340,6 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
);
}
}
}
// add feature id filter
this.writeNode("ogc:Filter", new OpenLayers.Filter.FeatureId({
@@ -412,13 +410,11 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
var parts = [];
var uri;
for(var key in schemaLocations) {
if (schemaLocations.hasOwnProperty(key)) {
uri = this.namespaces[key];
if(uri) {
parts.push(uri + " " + schemaLocations[key]);
}
}
}
var value = parts.join(" ") || undefined;
return value;
},
-8
View File
@@ -48,13 +48,11 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
prefix = this.namespaces[this.defaultPrefix];
} else {
for(prefix in this.namespaces) {
if (this.namespaces.hasOwnProperty(prefix)) {
if(this.namespaces[prefix] == uri) {
break;
}
}
}
}
return prefix;
},
@@ -676,7 +674,6 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
setAttributes: function(node, obj) {
var value;
for(var name in obj) {
if (obj.hasOwnProperty(name)) {
value = obj[name].toString();
if(value.match(/[A-Z]/)) {
// safari lowercases attributes with setAttribute
@@ -685,7 +682,6 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
node.setAttribute(name, value);
}
}
}
},
/**
@@ -1095,18 +1091,15 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
userValue: true
};
for (var dim in context.dimensions) {
if (context.dimensions.hasOwnProperty(dim)) {
var attributes = {};
var dimension = context.dimensions[dim];
for (var name in dimension) {
if (dimension.hasOwnProperty(name)) {
if (typeof dimension[name] == "boolean") {
attributes[name] = Number(dimension[name]);
} else {
attributes[name] = dimension[name];
}
}
}
var values = "";
if (attributes.values) {
values = attributes.values.join(",");
@@ -1117,7 +1110,6 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
"Dimension", values, attributes
));
}
}
return node;
},
-2
View File
@@ -122,11 +122,9 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
// optional SRS element(s)
if (context.srs) {
for(var name in context.srs) {
if (context.srs.hasOwnProperty(name)) {
node.appendChild(this.createElementDefaultNS("SRS", name));
}
}
}
// optional FormatList element
node.appendChild(this.write_wmc_FormatList(context));
@@ -84,12 +84,10 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
matrixSet: true
};
for (var prop in required) {
if (required.hasOwnProperty(prop)) {
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
}
}
var contents = capabilities.contents;
var matrixSet = contents.tileMatrixSets[config.matrixSet];
-4
View File
@@ -89,10 +89,8 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
this.namespaces = OpenLayers.Util.extend({}, this.namespaces);
this.namespaceAlias = {};
for(var alias in this.namespaces) {
if (this.namespaces.hasOwnProperty(alias)) {
this.namespaceAlias[this.namespaces[alias]] = alias;
}
}
},
/**
@@ -560,7 +558,6 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
setAttributes: function(node, obj) {
var value, uri;
for(var name in obj) {
if (obj.hasOwnProperty(name)) {
if(obj[name] != null && obj[name].toString) {
value = obj[name].toString();
// check for qualified attribute name ("prefix:local")
@@ -568,7 +565,6 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
this.setAttributeNS(node, uri, name, value);
}
}
}
},
/**
-2
View File
@@ -423,10 +423,8 @@ OpenLayers.Layer = OpenLayers.Class({
getOptions: function() {
var options = {};
for(var o in this.options) {
if (this.options.hasOwnProperty(o)) {
options[o] = this[o];
}
}
return options;
},
-2
View File
@@ -218,12 +218,10 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
var urlParams =
OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
}
paramsString = OpenLayers.Util.getParameterString(allParams);
return OpenLayers.Util.urlAppend(url, paramsString);
-2
View File
@@ -346,12 +346,10 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
}
var paramsString = OpenLayers.Util.getParameterString(allParams);
/* MapGuide needs '+' seperating things like bounds/height/width.
-2
View File
@@ -142,12 +142,10 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
var urlParams = OpenLayers.Util.upperCaseObject(
OpenLayers.Util.getParameters(url));
for(var key in allParams) {
if (allParams.hasOwnProperty(key)) {
if(key.toUpperCase() in urlParams) {
delete allParams[key];
}
}
}
paramsString = OpenLayers.Util.getParameterString(allParams);
// requestString always starts with url
-2
View File
@@ -509,14 +509,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
if(!zoomChanged && coordSysUnchanged) {
for(var i in this.unrenderedFeatures) {
if (this.unrenderedFeatures.hasOwnProperty(i)) {
var feature = this.unrenderedFeatures[i];
this.drawFeature(feature);
}
}
}
}
}
if (!this.drawn || (!ng && (zoomChanged || !coordSysUnchanged))) {
this.drawn = true;
var feature;
-2
View File
@@ -229,12 +229,10 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
matrixSet: true
};
for (var prop in required) {
if (required.hasOwnProperty(prop)) {
if (!(prop in config)) {
throw new Error("Missing property '" + prop + "' in layer configuration.");
}
}
}
config.params = OpenLayers.Util.upperCaseObject(config.params);
var args = [config.name, config.url, config.params, config];
+1 -1
View File
@@ -630,7 +630,7 @@ OpenLayers.Map = OpenLayers.Class({
delete this.center;
this.addLayers(options.layers);
// set center (and optionally zoom)
if (options.center) {
if (options.center && !this.getCenter()) {
// zoom can be undefined here
this.setCenter(options.center, options.zoom);
}
-2
View File
@@ -311,11 +311,9 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
this.destroyRequest(response.priv);
} else {
for (var key in this.pendingRequests) {
if (this.pendingRequests.hasOwnProperty(key)) {
this.destroyRequest(this.pendingRequests[key]);
}
}
}
},
/**
-2
View File
@@ -181,10 +181,8 @@ OpenLayers.Request = {
config.method, url, config.async, config.user, config.password
);
for(var header in config.headers) {
if (config.headers.hasOwnProperty(header)) {
request.setRequestHeader(header, config.headers[header]);
}
}
var events = this.events;
-4
View File
@@ -128,10 +128,8 @@ OpenLayers.Rule = OpenLayers.Class({
*/
destroy: function() {
for (var i in this.symbolizer) {
if (this.symbolizer.hasOwnProperty(i)) {
this.symbolizer[i] = null;
}
}
this.symbolizer = null;
delete this.symbolizers;
},
@@ -218,7 +216,6 @@ OpenLayers.Rule = OpenLayers.Class({
options.symbolizer = {};
var value, type;
for(var key in this.symbolizer) {
if (this.symbolizer.hasOwnProperty(key)) {
value = this.symbolizer[key];
type = typeof value;
if(type === "object") {
@@ -228,7 +225,6 @@ OpenLayers.Rule = OpenLayers.Class({
}
}
}
}
// clone filter
options.filter = this.filter && this.filter.clone();
// clone context
-6
View File
@@ -273,10 +273,8 @@ OpenLayers.Style = OpenLayers.Class({
OpenLayers.Util.extend(context, this.context);
for (var i in this.propertyStyles) {
if (this.propertyStyles.hasOwnProperty(i)) {
style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);
}
}
return style;
},
@@ -303,7 +301,6 @@ OpenLayers.Style = OpenLayers.Class({
for (var i=0, len=rules.length; i<len; i++) {
symbolizer = rules[i].symbolizer;
for (var key in symbolizer) {
if (symbolizer.hasOwnProperty(key)) {
value = symbolizer[key];
if (typeof value == "object") {
// symbolizer key is "Point", "Line" or "Polygon"
@@ -315,7 +312,6 @@ OpenLayers.Style = OpenLayers.Class({
}
}
}
}
return propertyStyles;
},
@@ -333,14 +329,12 @@ OpenLayers.Style = OpenLayers.Class({
addPropertyStyles: function(propertyStyles, symbolizer) {
var property;
for (var key in symbolizer) {
if (symbolizer.hasOwnProperty(key)) {
property = symbolizer[key];
if (typeof property == "string" &&
property.match(/\$\{\w+\}/)) {
propertyStyles[key] = true;
}
}
}
return propertyStyles;
},
-6
View File
@@ -63,7 +63,6 @@ OpenLayers.StyleMap = OpenLayers.Class({
this.styles["delete"] = style;
} else if(typeof style == "object") {
for(var key in style) {
if (style.hasOwnProperty(key)) {
if(style[key] instanceof OpenLayers.Style) {
// user passed a hash of style objects
this.styles[key] = style[key];
@@ -80,7 +79,6 @@ OpenLayers.StyleMap = OpenLayers.Class({
}
}
}
}
OpenLayers.Util.extend(this, options);
},
@@ -89,10 +87,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
*/
destroy: function() {
for(var key in this.styles) {
if (this.styles.hasOwnProperty(key)) {
this.styles[key].destroy();
}
}
this.styles = null;
},
@@ -148,7 +144,6 @@ OpenLayers.StyleMap = OpenLayers.Class({
addUniqueValueRules: function(renderIntent, property, symbolizers, context) {
var rules = [];
for (var value in symbolizers) {
if (symbolizers.hasOwnProperty(value)) {
rules.push(new OpenLayers.Rule({
symbolizer: symbolizers[value],
context: context,
@@ -159,7 +154,6 @@ OpenLayers.StyleMap = OpenLayers.Class({
})
}));
}
}
this.styles[renderIntent].addRules(rules);
},
-2
View File
@@ -163,14 +163,12 @@ OpenLayers.Tile.Image.IFrame = {
field;
for(var par in params) {
if (params.hasOwnProperty(par)) {
field = document.createElement('input');
field.type = 'hidden';
field.name = par;
field.value = params[par];
form.appendChild(field);
}
}
return form;
},
-2
View File
@@ -127,7 +127,6 @@ OpenLayers.Tween = OpenLayers.Class({
play: function() {
var value = {};
for (var i in this.begin) {
if (this.begin.hasOwnProperty(i)) {
var b = this.begin[i];
var f = this.finish[i];
if (b == null || f == null || isNaN(b) || isNaN(f)) {
@@ -137,7 +136,6 @@ OpenLayers.Tween = OpenLayers.Class({
var c = f - b;
value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);
}
}
this.time++;
if (this.callbacks && this.callbacks.eachStep) {
+3 -13
View File
@@ -441,10 +441,8 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
OpenLayers.Util.upperCaseObject = function (object) {
var uObject = {};
for (var key in object) {
if (object.hasOwnProperty(key)) {
uObject[key.toUpperCase()] = object[key];
}
}
return uObject;
};
@@ -511,7 +509,6 @@ OpenLayers.Util.getParameterString = function(params) {
var paramsArray = [];
for (var key in params) {
if (params.hasOwnProperty(key)) {
var value = params[key];
if ((value != null) && (typeof value != 'function')) {
var encodedValue;
@@ -534,7 +531,6 @@ OpenLayers.Util.getParameterString = function(params) {
paramsArray.push(encodeURIComponent(key) + "=" + encodedValue);
}
}
}
return paramsArray.join("&");
};
@@ -1304,31 +1300,25 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
var urlObj2 = OpenLayers.Util.createUrlObject(url2, options);
//compare all keys except for "args" (treated below)
for (var key in urlObj1) {
if (urlObj1.hasOwnProperty(key)) {
for(var key in urlObj1) {
if(key !== "args") {
if(urlObj1[key] != urlObj2[key]) {
return false;
}
}
}
}
// compare search args - irrespective of order
for (var key in urlObj1.args) {
if (urlObj1.args.hasOwnProperty(key)) {
for(var key in urlObj1.args) {
if(urlObj1.args[key] != urlObj2.args[key]) {
return false;
}
delete urlObj2.args[key];
}
}
// urlObj2 shouldn't have any args left
for (var key in urlObj2.args) {
if (urlObj2.args.hasOwnProperty(key)) {
for(var key in urlObj2.args) {
return false;
}
}
return true;
};
+3 -3
View File
@@ -289,16 +289,16 @@
// move 10 pixels
trigger("mousemove", 0, 10);
t.eq(log.length, 0, "a) no event fired yet");
t.eq(log.length, 1, "a) has fired an event");
t.delay_call(
delay, function() {
// confirm measurepartial is fired
t.eq(log.length, 1, "a) event logged");
t.eq(log.length, 1, "a) one event logged");
t.ok(log[0] && log[0].type == "measurepartial", "a) correct type");
// mousemove within the partialDelay fires no event, so the
// measure below is the one of the initial point
t.ok(log[0] && log[0].measure == 0, "a) correct measure");
t.eq(log[0]?log[0].measure:-1 , 10, "a) correct measure");
// b) move 10 pixels
trigger("mousemove", 0, 20);
+72 -4
View File
@@ -11,6 +11,7 @@
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink', 'test.html');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -18,6 +19,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink('permalink');
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -25,6 +27,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -32,6 +35,7 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -39,18 +43,21 @@
t.eq(control.base, document.location.href, "base is correct");
t.ok(control.element == null, "element is null");
t.ok(control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({anchor: false});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
t.eq(control.base, document.location.href, "base is correct");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -58,6 +65,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(!control.anchor, "anchor is correct");
control.destroy();
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
@@ -65,6 +73,7 @@
t.eq(control.base, 'test.html', "base is correct");
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
t.ok(control.anchor, "anchor is correct");
control.destroy();
}
function test_Control_Permalink_uncentered (t) {
t.plan( 1 );
@@ -74,12 +83,14 @@
map.addControl(control);
map.events.triggerEvent("changelayer", {});
t.ok(true, "permalink didn't bomb out.");
map.destroy();
}
function test_Control_Permalink_initwithelem (t) {
t.plan( 1 );
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
t.ok(true, "If the above line doesn't throw an error, we're safe.");
control.destroy();
}
function test_Control_Permalink_updateLinks (t) {
t.plan( 3 );
@@ -100,6 +111,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_updateLinksBase (t) {
t.plan( 2 );
@@ -114,6 +126,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
map.destroy();
}
function test_Control_Permalink_noElement (t) {
t.plan( 2 );
@@ -122,6 +135,7 @@
map = new OpenLayers.Map('map');
map.addControl(control);
t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
map.destroy();
}
function test_Control_Permalink_base_with_query (t) {
t.plan( 3 );
@@ -147,6 +161,7 @@
map.pan(5, 0, {animate:false});
map.pan(-5, 0, {animate:false});
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
map.destroy();
}
@@ -163,6 +178,7 @@
map.pan(5, 0, {animate:false});
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
map.destroy();
}
function test_Control_Permalink_customized(t) {
@@ -189,6 +205,7 @@
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
map.destroy();
}
function test_Control_Permalink_createParams(t) {
@@ -300,6 +317,7 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_Control_Permalink_AnchorBaseElement (t) {
@@ -320,10 +338,15 @@
map.layers[1].setVisibility(false);
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
map.destroy();
}
function test_arrayCenter(t) {
t.plan(1);
function test_center_from_map(t) {
t.plan(7);
var previous = window.location.hash;
window.location.hash = "";
var err;
try {
var map = new OpenLayers.Map({
@@ -331,8 +354,8 @@
controls: [
new OpenLayers.Control.Permalink({anchor: true})
],
center: [0, 0],
zoom: 1
center: [1, 2],
zoom: 3
});
} catch (e) {
err = e;
@@ -342,6 +365,51 @@
} else {
t.ok(true, "Map construction works");
}
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 1, "map x");
t.eq(center.lat, 2, "map y")
t.eq(map.getZoom(), 3, "map z");
// confirm that location from map options has been added to url
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "1", "url x");
t.eq(params.lat, "2", "url y");
t.eq(params.zoom, "3", "url z");
map.destroy();
window.location.hash = previous;
}
function test_center_from_url(t) {
t.plan(6);
// In cases where the location is specified in the URL and given in
// the map options, we respect the location in the URL.
var previous = window.location.hash;
window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
var map = new OpenLayers.Map({
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
controls: [new OpenLayers.Control.Permalink({anchor: true})],
center: [0, 0],
zoom: 0
});
// confirm that map center is correctly set
var center = map.getCenter();
t.eq(center.lon, 4, "map x");
t.eq(center.lat, 5, "map y")
t.eq(map.getZoom(), 6, "map z");
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
t.eq(params.lon, "4", "x set");
t.eq(params.lat, "5", "y set");
t.eq(params.zoom, "6", "z set");
map.destroy();
window.location.hash = previous;
}
</script>