More robust array type check. p=mwootendev, r=me (closes #2959)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12095 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -478,7 +478,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
if(!this.modifiers.multiple && !this.modifiers.toggle) {
|
||||
this.unselectAll();
|
||||
}
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.deleteCodes = [46, 68];
|
||||
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
if(!(this.deleteCodes instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(this.deleteCodes))) {
|
||||
this.deleteCodes = [this.deleteCodes];
|
||||
}
|
||||
var control = this;
|
||||
|
||||
@@ -232,7 +232,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* controls - {<OpenLayers.Control>} Controls to add in the panel.
|
||||
*/
|
||||
addControls: function(controls) {
|
||||
if (!(controls instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(controls))) {
|
||||
controls = [controls];
|
||||
}
|
||||
this.controls = this.controls.concat(controls);
|
||||
|
||||
@@ -218,7 +218,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layers - {<OpenLayers.Layer.Vector>}, or an array of vector layers.
|
||||
*/
|
||||
initLayer: function(layers) {
|
||||
if(layers instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(layers)) {
|
||||
this.layers = layers;
|
||||
this.layer = new OpenLayers.Layer.Vector.RootContainer(
|
||||
this.id + "_container", {
|
||||
|
||||
@@ -300,7 +300,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
layer = candidates[i];
|
||||
if(layer instanceof OpenLayers.Layer.WMS &&
|
||||
(!this.queryVisible || layer.getVisibility())) {
|
||||
url = layer.url instanceof Array ? layer.url[0] : layer.url;
|
||||
url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
|
||||
// if the control was not configured with a url, set it
|
||||
// to the first layer url
|
||||
if(this.drillDown === false && !this.url) {
|
||||
@@ -421,7 +421,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (layer.params.STYLES) {
|
||||
styleNames = layer.params.STYLES;
|
||||
} else {
|
||||
if (layer.params.LAYERS instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(layer.params.LAYERS)) {
|
||||
styleNames = new Array(layer.params.LAYERS.length);
|
||||
} else { // Assume it's a String
|
||||
styleNames = layer.params.LAYERS.replace(/[^,]/g, "");
|
||||
@@ -469,7 +469,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
for(var i=0, len=layers.length; i<len; i++) {
|
||||
var layer = layers[i];
|
||||
var service, found = false;
|
||||
url = layer.url instanceof Array ? layer.url[0] : layer.url;
|
||||
url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
|
||||
if(url in services) {
|
||||
services[url].push(layer);
|
||||
} else {
|
||||
|
||||
@@ -299,7 +299,7 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
});
|
||||
OpenLayers.Util.applyDefaults(params, this.vendorParams);
|
||||
return {
|
||||
url: layer.url instanceof Array ? layer.url[0] : layer.url,
|
||||
url: OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url,
|
||||
params: OpenLayers.Util.upperCaseObject(params),
|
||||
callback: function(request) {
|
||||
this.handleResponse(xy, request, layer);
|
||||
|
||||
@@ -496,7 +496,7 @@ OpenLayers.Format.ArcXML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
|
||||
addRenderer: function(topRelem, renderer) {
|
||||
if (renderer instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(renderer)) {
|
||||
this.addGroupRenderer(topRelem, renderer);
|
||||
} else {
|
||||
var renderElem = this.createElementNS("", renderer.type.toUpperCase() + "RENDERER");
|
||||
|
||||
@@ -99,7 +99,7 @@ OpenLayers.Format.Atom = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
write: function(features) {
|
||||
var doc;
|
||||
if (features instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(features)) {
|
||||
doc = this.createElementNSPlus("atom:feed");
|
||||
doc.appendChild(
|
||||
this.createElementNSPlus("atom:title", {
|
||||
@@ -183,7 +183,7 @@ OpenLayers.Format.Atom = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
// atom:author
|
||||
if (atomAttrib.authors) {
|
||||
var authors = atomAttrib.authors instanceof Array ?
|
||||
var authors = OpenLayers.Util.isArray(atomAttrib.authors) ?
|
||||
atomAttrib.authors : [atomAttrib.authors];
|
||||
for (var i=0, ii=authors.length; i<ii; i++) {
|
||||
entryNode.appendChild(
|
||||
@@ -196,7 +196,7 @@ OpenLayers.Format.Atom = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
// atom:category
|
||||
if (atomAttrib.categories) {
|
||||
var categories = atomAttrib.categories instanceof Array ?
|
||||
var categories = OpenLayers.Util.isArray(atomAttrib.categories) ?
|
||||
atomAttrib.categories : [atomAttrib.categories];
|
||||
var category;
|
||||
for (var i=0, ii=categories.length; i<ii; i++) {
|
||||
@@ -220,7 +220,7 @@ OpenLayers.Format.Atom = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
// atom:contributor
|
||||
if (atomAttrib.contributors) {
|
||||
var contributors = atomAttrib.contributors instanceof Array ?
|
||||
var contributors = OpenLayers.Util.isArray(atomAttrib.contributors) ?
|
||||
atomAttrib.contributors : [atomAttrib.contributors];
|
||||
for (var i=0, ii=contributors.length; i<ii; i++) {
|
||||
entryNode.appendChild(
|
||||
@@ -243,7 +243,7 @@ OpenLayers.Format.Atom = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
|
||||
// atom:link
|
||||
if (atomAttrib.links) {
|
||||
var links = atomAttrib.links instanceof Array ?
|
||||
var links = OpenLayers.Util.isArray(atomAttrib.links) ?
|
||||
atomAttrib.links : [atomAttrib.links];
|
||||
var link;
|
||||
for (var i=0, ii=links.length; i<ii; i++) {
|
||||
|
||||
@@ -108,7 +108,7 @@ OpenLayers.Format.CSWGetDomain.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
"DomainValues": function(node, obj) {
|
||||
if (!(obj.DomainValues instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(obj.DomainValues))) {
|
||||
obj.DomainValues = [];
|
||||
}
|
||||
var attrs = node.attributes;
|
||||
@@ -126,7 +126,7 @@ OpenLayers.Format.CSWGetDomain.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
obj.ParameterName = this.getChildValue(node);
|
||||
},
|
||||
"ListOfValues": function(node, obj) {
|
||||
if (!(obj.ListOfValues instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(obj.ListOfValues))) {
|
||||
obj.ListOfValues = [];
|
||||
}
|
||||
this.readChildNodes(node, obj.ListOfValues);
|
||||
|
||||
@@ -253,7 +253,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
// rightsHolder, source, subject, title, type, URI
|
||||
"*": function(node, obj) {
|
||||
var name = node.localName || node.nodeName.split(":").pop();
|
||||
if (!(obj[name] instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(obj[name]))) {
|
||||
obj[name] = new Array();
|
||||
}
|
||||
var dc_element = {};
|
||||
@@ -269,7 +269,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
// abstract, modified, spatial
|
||||
"*": function(node, obj) {
|
||||
var name = node.localName || node.nodeName.split(":").pop();
|
||||
if (!(obj[name] instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(obj[name]))) {
|
||||
obj[name] = new Array();
|
||||
}
|
||||
obj[name].push(this.getChildValue(node));
|
||||
@@ -342,7 +342,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
);
|
||||
}
|
||||
var ResponseHandler = options.ResponseHandler || this.ResponseHandler;
|
||||
if (ResponseHandler instanceof Array && ResponseHandler.length > 0) {
|
||||
if (OpenLayers.Util.isArray(ResponseHandler) && ResponseHandler.length > 0) {
|
||||
// ResponseHandler must be a non-empty array
|
||||
for(var i=0, len=ResponseHandler.length; i<len; i++) {
|
||||
this.writeNode(
|
||||
@@ -379,7 +379,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML,
|
||||
}
|
||||
});
|
||||
var ElementName = options.ElementName;
|
||||
if (ElementName instanceof Array && ElementName.length > 0) {
|
||||
if (OpenLayers.Util.isArray(ElementName) && ElementName.length > 0) {
|
||||
// ElementName must be a non-empty array
|
||||
for(var i=0, len=ElementName.length; i<len; i++) {
|
||||
this.writeNode(
|
||||
|
||||
@@ -639,7 +639,7 @@ OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* {String} A string representing the GML document.
|
||||
*/
|
||||
write: function(features) {
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
var gml = this.createElementNS("http://www.opengis.net/wfs",
|
||||
|
||||
@@ -419,7 +419,7 @@ OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
write: function(features) {
|
||||
var name;
|
||||
if(features instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(features)) {
|
||||
name = "featureMembers";
|
||||
} else {
|
||||
name = "featureMember";
|
||||
|
||||
@@ -90,7 +90,7 @@ OpenLayers.Format.GML.v2 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
|
||||
*/
|
||||
write: function(features) {
|
||||
var name;
|
||||
if(features instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(features)) {
|
||||
// GML2 only has abstract feature collections
|
||||
// wfs provides a feature collection from a well-known schema
|
||||
name = "wfs:FeatureCollection";
|
||||
|
||||
@@ -250,7 +250,7 @@ OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {
|
||||
*/
|
||||
write: function(features) {
|
||||
var name;
|
||||
if(features instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(features)) {
|
||||
name = "featureMembers";
|
||||
} else {
|
||||
name = "featureMember";
|
||||
|
||||
@@ -219,7 +219,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
}
|
||||
var geometry, collection = false;
|
||||
if(obj.type == "GeometryCollection") {
|
||||
if(!(obj.geometries instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(obj.geometries))) {
|
||||
throw "GeometryCollection must have geometries array: " + obj;
|
||||
}
|
||||
var numGeom = obj.geometries.length;
|
||||
@@ -232,7 +232,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
geometry = new OpenLayers.Geometry.Collection(components);
|
||||
collection = true;
|
||||
} else {
|
||||
if(!(obj.coordinates instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(obj.coordinates))) {
|
||||
throw "Geometry must have coordinates array: " + obj;
|
||||
}
|
||||
if(!this.parseCoords[obj.type.toLowerCase()]) {
|
||||
@@ -450,7 +450,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
var geojson = {
|
||||
"type": null
|
||||
};
|
||||
if(obj instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(obj)) {
|
||||
geojson.type = "FeatureCollection";
|
||||
var numFeatures = obj.length;
|
||||
geojson.features = new Array(numFeatures);
|
||||
|
||||
@@ -297,7 +297,7 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
write: function(features) {
|
||||
var georss;
|
||||
if(features instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(features)) {
|
||||
georss = this.createElementNS(this.rssns, "rss");
|
||||
for(var i=0, len=features.length; i<len; i++) {
|
||||
georss.appendChild(this.createFeatureXML(features[i]));
|
||||
|
||||
@@ -1131,7 +1131,7 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* {String} A KML string.
|
||||
*/
|
||||
write: function(features) {
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
var kml = this.createElementNS(this.kmlns, "kml");
|
||||
|
||||
@@ -291,7 +291,7 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)}
|
||||
*/
|
||||
write: function(features) {
|
||||
if (!(features instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ OpenLayers.Format.OWSContext.v0_3_1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
decomposeNestingPath: function(nPath){
|
||||
var a = [];
|
||||
if (nPath instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(nPath)) {
|
||||
var path = nPath.slice();
|
||||
while (path.length > 0) {
|
||||
a.push(path.slice());
|
||||
|
||||
@@ -147,7 +147,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
|
||||
for(var i=0, len=layer.userStyles.length; i<len; ++i) {
|
||||
layer.userStyles[i].layerName = layer.name;
|
||||
}
|
||||
if(sld.namedLayers instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(sld.namedLayers)) {
|
||||
sld.namedLayers.push(layer);
|
||||
} else {
|
||||
sld.namedLayers[layer.name] = layer;
|
||||
@@ -558,7 +558,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, {
|
||||
}
|
||||
// add in named layers
|
||||
// allow namedLayers to be an array
|
||||
if(sld.namedLayers instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(sld.namedLayers)) {
|
||||
for(var i=0, len=sld.namedLayers.length; i<len; ++i) {
|
||||
this.writeNode("NamedLayer", sld.namedLayers[i], root);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ OpenLayers.Format.WMC = OpenLayers.Class(OpenLayers.Format.Context, {
|
||||
}
|
||||
|
||||
// let's convert layers into layersContext object (if any)
|
||||
if (layers != undefined && layers instanceof Array) {
|
||||
if (layers != undefined && OpenLayers.Util.isArray(layers)) {
|
||||
for (var i=0, len=layers.length; i<len; i++) {
|
||||
var layer = layers[i];
|
||||
if (layer instanceof OpenLayers.Layer.WMS) {
|
||||
|
||||
@@ -1154,7 +1154,7 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
var node = this.createElementDefaultNS("StyleList");
|
||||
|
||||
var styles = layer.styles;
|
||||
if (styles && styles instanceof Array) {
|
||||
if (styles && OpenLayers.Util.isArray(styles)) {
|
||||
var sld;
|
||||
for (var i=0, len=styles.length; i<len; i++) {
|
||||
var s = styles[i];
|
||||
|
||||
@@ -296,7 +296,7 @@ OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class(
|
||||
this.readChildNodes(node, obj.getcapabilities);
|
||||
},
|
||||
"Format": function(node, obj) {
|
||||
if (obj.formats instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(obj.formats)) {
|
||||
obj.formats.push(this.getChildValue(node));
|
||||
} else {
|
||||
obj.format = this.getChildValue(node);
|
||||
|
||||
@@ -258,7 +258,7 @@ OpenLayers.Format.XLS.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
this.writeNode(node, "Building", address.building);
|
||||
}
|
||||
var street = address.street;
|
||||
if (!(street instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(street))) {
|
||||
street = [street];
|
||||
}
|
||||
for (var i=0, len=street.length; i < len; i++) {
|
||||
|
||||
@@ -274,7 +274,7 @@ OpenLayers.Geometry.fromWKT = function(wkt) {
|
||||
var result = format.read(wkt);
|
||||
if(result instanceof OpenLayers.Feature.Vector) {
|
||||
geom = result.geometry;
|
||||
} else if(result instanceof Array) {
|
||||
} else if(OpenLayers.Util.isArray(result)) {
|
||||
var len = result.length;
|
||||
var components = new Array(len);
|
||||
for(var i=0; i<len; ++i) {
|
||||
|
||||
@@ -131,7 +131,7 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
||||
* components - {Array(<OpenLayers.Geometry>)} An array of geometries to add
|
||||
*/
|
||||
addComponents: function(components){
|
||||
if(!(components instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(components))) {
|
||||
components = [components];
|
||||
}
|
||||
for(var i=0, len=components.length; i<len; i++) {
|
||||
@@ -185,7 +185,7 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
||||
* components - {Array(<OpenLayers.Geometry>)} The components to be removed
|
||||
*/
|
||||
removeComponents: function(components) {
|
||||
if(!(components instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(components))) {
|
||||
components = [components];
|
||||
}
|
||||
for(var i=components.length-1; i>=0; --i) {
|
||||
@@ -468,7 +468,7 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
||||
if(!geometry || !geometry.CLASS_NAME ||
|
||||
(this.CLASS_NAME != geometry.CLASS_NAME)) {
|
||||
equivalent = false;
|
||||
} else if(!(geometry.components instanceof Array) ||
|
||||
} else if(!(OpenLayers.Util.isArray(geometry.components)) ||
|
||||
(geometry.components.length != this.components.length)) {
|
||||
equivalent = false;
|
||||
} else {
|
||||
|
||||
@@ -430,7 +430,7 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
||||
var url = this.url;
|
||||
var s = '' + x + y + z;
|
||||
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(s, url);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
||||
// in which case we will deterministically select one of them in
|
||||
// order to evenly distribute requests to different urls.
|
||||
//
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(paramsString, url);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ OpenLayers.Layer.KaMapCache = OpenLayers.Class(OpenLayers.Layer.KaMap, {
|
||||
// order to evenly distribute requests to different urls.
|
||||
//
|
||||
var url = this.url;
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(paramsString, url);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
// if url is not a string, it should be an array of strings,
|
||||
// in which case we will deterministically select one of them in
|
||||
// order to evenly distribute requests to different urls.
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(paramsString, url);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
this.map.getZoom() + this.zoomOffset;
|
||||
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
|
||||
var url = this.url;
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(path, url);
|
||||
}
|
||||
return url + path;
|
||||
|
||||
@@ -138,7 +138,7 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
];
|
||||
var path = components.join('/');
|
||||
var url = this.url;
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(path, url);
|
||||
}
|
||||
url = (url.charAt(url.length - 1) == '/') ? url : url + '/';
|
||||
|
||||
@@ -554,7 +554,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* options - {Object}
|
||||
*/
|
||||
addFeatures: function(features, options) {
|
||||
if (!(features instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
if (features === this.features) {
|
||||
return this.removeAllFeatures(options);
|
||||
}
|
||||
if (!(features instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
if (features === this.selectedFeatures) {
|
||||
|
||||
@@ -408,7 +408,7 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
path = path + this.matrixSet + "/" + this.matrix.identifier +
|
||||
"/" + info.row + "/" + info.col + "." + this.formatSuffix;
|
||||
|
||||
if (this.url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(this.url)) {
|
||||
url = this.selectUrl(path, this.url);
|
||||
} else {
|
||||
url = this.url;
|
||||
|
||||
@@ -120,7 +120,7 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
getURL: function (bounds) {
|
||||
var xyz = this.getXYZ(bounds);
|
||||
var url = this.url;
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
var s = '' + xyz.x + xyz.y + xyz.z;
|
||||
url = this.selectUrl(s, url);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) +
|
||||
"/" + z + "-" + x + "-" + y + ".jpg";
|
||||
var url = this.url;
|
||||
if (url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(url)) {
|
||||
url = this.selectUrl(path, url);
|
||||
}
|
||||
return url + path;
|
||||
|
||||
@@ -302,7 +302,7 @@ OpenLayers.Protocol.SQL.Gears = OpenLayers.Class(OpenLayers.Protocol.SQL, {
|
||||
* object.
|
||||
*/
|
||||
createOrUpdate: function(features) {
|
||||
if (!(features instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ OpenLayers.Protocol.SQL.Gears = OpenLayers.Class(OpenLayers.Protocol.SQL, {
|
||||
* object.
|
||||
*/
|
||||
"delete": function(features, options) {
|
||||
if (!(features instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ OpenLayers.Protocol.WFS = function(options) {
|
||||
OpenLayers.Protocol.WFS.fromWMSLayer = function(layer, options) {
|
||||
var typeName, featurePrefix;
|
||||
var param = layer.params["LAYERS"];
|
||||
var parts = (param instanceof Array ? param[0] : param).split(":");
|
||||
var parts = (OpenLayers.Util.isArray(param) ? param[0] : param).split(":");
|
||||
if(parts.length > 1) {
|
||||
featurePrefix = parts[0];
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ OpenLayers.Renderer = OpenLayers.Class({
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)}
|
||||
*/
|
||||
eraseFeatures: function(features) {
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
for(var i=0, len=features.length; i<len; ++i) {
|
||||
|
||||
@@ -632,7 +632,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)}
|
||||
*/
|
||||
eraseFeatures: function(features) {
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
for(var i=0; i<features.length; ++i) {
|
||||
|
||||
@@ -373,7 +373,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
}
|
||||
|
||||
// needed for changing to a different server for onload error
|
||||
if (this.layer.url instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(this.layer.url)) {
|
||||
this.imgDiv.urls = this.layer.url.slice();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,22 @@ OpenLayers.Util.isElement = function(o) {
|
||||
return !!(o && o.nodeType === 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: isArray
|
||||
* Tests that the provided object is an array.
|
||||
* This test handles the cross-IFRAME case not caught
|
||||
* by "a instanceof Array" and should be used instead.
|
||||
*
|
||||
* Parameters:
|
||||
* a - {Object} the object test.
|
||||
*
|
||||
* Returns
|
||||
* {Boolean} true if the object is an array.
|
||||
*/
|
||||
OpenLayers.Util.isArray = function(a) {
|
||||
return (Object.prototype.toString.call(a) === '[object Array]');
|
||||
};
|
||||
|
||||
/**
|
||||
* Maintain existing definition of $.
|
||||
*/
|
||||
@@ -346,7 +362,7 @@ OpenLayers.Util.onImageLoadError = function() {
|
||||
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
|
||||
if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
|
||||
var urls = this.urls;
|
||||
if (urls && urls instanceof Array && urls.length > 1){
|
||||
if (urls && OpenLayers.Util.isArray(urls) && urls.length > 1){
|
||||
var src = this.src.toString();
|
||||
var current_url, k;
|
||||
for (k = 0; current_url = urls[k]; k++){
|
||||
|
||||
@@ -41,6 +41,28 @@
|
||||
"isElement reports that object returned by getElement is an Element");
|
||||
}
|
||||
|
||||
function test_isArray(t) {
|
||||
t.plan(5);
|
||||
|
||||
var a;
|
||||
|
||||
a = null;
|
||||
t.eq(OpenLayers.Util.isArray(a), false,
|
||||
"isArray reports 'null' isn't an Array");
|
||||
a = "Array";
|
||||
t.eq(OpenLayers.Util.isArray(a), false,
|
||||
"isArray reports \"Array\" isn't an Array");
|
||||
a = {};
|
||||
t.eq(OpenLayers.Util.isArray(a), false,
|
||||
"isArray reports {} isn't an Array");
|
||||
a = [];
|
||||
t.eq(OpenLayers.Util.isArray(a), true,
|
||||
"isArray reports [] is an Array");
|
||||
a = new Array();
|
||||
t.eq(OpenLayers.Util.isArray(a), true,
|
||||
"isArray reports new Array() is an Array");
|
||||
}
|
||||
|
||||
function test_$(t) {
|
||||
t.plan(1);
|
||||
t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");
|
||||
|
||||
Reference in New Issue
Block a user