⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v1.js

📁 OpenLayers-2.6 api 函数
💻 JS
📖 第 1 页 / 共 3 页
字号:
                                if(symbolizer.graphicOpacity != undefined) {                    this.writeNode(node, "Opacity", symbolizer.graphicOpacity);                }                if(symbolizer.pointRadius != undefined) {                    this.writeNode(node, "Size", symbolizer.pointRadius);                }                if(symbolizer.rotation != undefined) {                    this.writeNode(node, "Rotation", symbolizer.rotation);                }                return node;            },            "ExternalGraphic": function(symbolizer) {                var node = this.createElementNSPlus("ExternalGraphic");                this.writeNode(                    node, "OnlineResource", symbolizer.externalGraphic                );                var format = symbolizer.graphicFormat ||                             this.getGraphicFormat(symbolizer.externalGraphic);                this.writeNode(node, "Format", format);                return node;            },            "Mark": function(symbolizer) {                var node = this.createElementNSPlus("Mark");                this.writeNode(node, "WellKnownName", symbolizer.graphicName);                this.writeNode(node, "Fill", symbolizer);                this.writeNode(node, "Stroke", symbolizer);                return node;            },            "WellKnownName": function(name) {                return this.createElementNSPlus("WellKnownName", {                    value: name                });            },            "Opacity": function(value) {                return this.createElementNSPlus("Opacity", {                    value: value                });            },            "Size": function(value) {                return this.createElementNSPlus("Size", {                    value: value                });            },            "Rotation": function(value) {                return this.createElementNSPlus("Rotation", {                    value: value                });            },            "OnlineResource": function(href) {                return this.createElementNSPlus("OnlineResource", {                    attributes: {                        "xlink:type": "simple",                        "xlink:href": href                    }                });            },            "Format": function(format) {                return this.createElementNSPlus("Format", {                    value: format                });            }        },        "ogc": {            "Filter": function(filter) {                var node = this.createElementNSPlus("ogc:Filter");                var sub = filter.CLASS_NAME.split(".").pop();                if(sub == "FeatureId") {                    for(var i=0; i<filter.fids.length; ++i) {                        this.writeNode(node, "FeatureId", filter.fids[i]);                    }                } else {                    this.writeNode(node, this.getFilterType(filter), filter);                }                return node;            },            "FeatureId": function(fid) {                return this.createElementNSPlus("ogc:FeatureId", {                    attributes: {fid: fid}                });            },            "And": function(filter) {                var node = this.createElementNSPlus("ogc:And");                var childFilter;                for(var i=0; i<filter.filters.length; ++i) {                    childFilter = filter.filters[i];                    this.writeNode(                        node, this.getFilterType(childFilter), childFilter                    );                }                return node;            },            "Or": function(filter) {                var node = this.createElementNSPlus("ogc:Or");                var childFilter;                for(var i=0; i<filter.filters.length; ++i) {                    childFilter = filter.filters[i];                    this.writeNode(                        node, this.getFilterType(childFilter), childFilter                    );                }                return node;            },            "Not": function(filter) {                var node = this.createElementNSPlus("ogc:Not");                var childFilter = filter.filters[0];                this.writeNode(                    node, this.getFilterType(childFilter), childFilter                );                return node;            },            "PropertyIsEqualTo": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                return node;            },            "PropertyIsNotEqualTo": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                return node;            },            "PropertyIsLessThan": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsLessThan");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                                return node;            },            "PropertyIsGreaterThan": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                return node;            },            "PropertyIsLessThanOrEqualTo": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                return node;            },            "PropertyIsGreaterThanOrEqualTo": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "Literal", filter.value);                return node;            },            "PropertyIsBetween": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsBetween");                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                this.writeNode(node, "LowerBoundary", filter);                this.writeNode(node, "UpperBoundary", filter);                return node;            },            "PropertyIsLike": function(filter) {                var node = this.createElementNSPlus("ogc:PropertyIsLike", {                    attributes: {                        wildCard: "*", singleChar: ".", escape: "!"                    }                });                // no ogc:expression handling for now                this.writeNode(node, "PropertyName", filter);                // convert regex string to ogc string                this.writeNode(node, "Literal", filter.regex2value());                return node;            },            "PropertyName": function(filter) {                // no ogc:expression handling for now                return this.createElementNSPlus("ogc:PropertyName", {                    value: filter.property                });            },            "Literal": function(value) {                // no ogc:expression handling for now                return this.createElementNSPlus("ogc:Literal", {                    value: value                });            },            "LowerBoundary": function(filter) {                // no ogc:expression handling for now                var node = this.createElementNSPlus("ogc:LowerBoundary");                this.writeNode(node, "Literal", filter.lowerBoundary);                return node;            },            "UpperBoundary": function(filter) {                // no ogc:expression handling for now                var node = this.createElementNSPlus("ogc:UpperBoundary");                this.writeNode(node, "Literal", filter.upperBoundary);                return node;            }        }    },        /**     * Method: getFilterType     */    getFilterType: function(filter) {        var filterType = this.filterMap[filter.type];        if(!filterType) {            throw "SLD writing not supported for rule type: " + filter.type;        }        return filterType;    },        /**     * Property: filterMap     * {Object} Contains a member for each filter type.  Values are node names     *     for corresponding OGC Filter child elements.     */    filterMap: {        "&&": "And",        "||": "Or",        "!": "Not",        "==": "PropertyIsEqualTo",        "!=": "PropertyIsNotEqualTo",        "<": "PropertyIsLessThan",        ">": "PropertyIsGreaterThan",        "<=": "PropertyIsLessThanOrEqualTo",        ">=": "PropertyIsGreaterThanOrEqualTo",        "..": "PropertyIsBetween",        "~": "PropertyIsLike"    },        /**     * Methods below this point are of general use for versioned XML parsers.     * These are candidates for an abstract class.     */        /**     * Method: getNamespacePrefix     * Get the namespace prefix for a given uri from the <namespaces> object.     *     * Returns:     * {String} A namespace prefix or null if none found.     */    getNamespacePrefix: function(uri) {        var prefix = null;        if(uri == null) {            prefix = this.namespaces[this.defaultPrefix];        } else {            var gotPrefix = false;            for(prefix in this.namespaces) {                if(this.namespaces[prefix] == uri) {                    gotPrefix = true;                    break;                }            }            if(!gotPrefix) {                prefix = null;            }        }        return prefix;    },    /**     * Method: readChildNodes     */    readChildNodes: function(node, obj) {        var children = node.childNodes;        var child, group, reader, prefix, local;        for(var i=0; i<children.length; ++i) {            child = children[i];            if(child.nodeType == 1) {                prefix = this.getNamespacePrefix(child.namespaceURI);                local = child.nodeName.split(":").pop();                group = this.readers[prefix];                if(group) {                    reader = group[local];                    if(reader) {                        reader.apply(this, [child, obj]);                    }                }            }        }    },    /**     * Method: writeNode     * Shorthand for applying one of the named writers and appending the     *     results to a node.  If a qualified name is not provided for the     *     second argument (and a local name is used instead), the namespace     *     of the parent node will be assumed.     *     * Parameters:     * parent - {DOMElement} Result will be appended to this node.     * name - {String} The name of a node to generate.  If a qualified name     *     (e.g. "pre:Name") is used, the namespace prefix is assumed to be     *     in the <writers> group.  If a local name is used (e.g. "Name") then     *     the namespace of the parent is assumed.     * obj - {Object} Structure containing data for the writer.     *     * Returns:     * {DOMElement} The child node.     */    writeNode: function(parent, name, obj) {        var prefix, local;        var split = name.indexOf(":");        if(split > 0) {            prefix = name.substring(0, split);            local = name.substring(split + 1);        } else {            prefix = this.getNamespacePrefix(parent.namespaceURI);            local = name;        }        var child = this.writers[prefix][local].apply(this, [obj]);        parent.appendChild(child);        return child;    },        /**     * Method: createElementNSPlus     * Shorthand for creating namespaced elements with optional attributes and     *     child text nodes.     *     * Parameters:     * name - {String} The qualified node name.     * options - {Object} Optional object for node configuration.     *     * Returns:     * {Element} An element node.     */    createElementNSPlus: function(name, options) {        options = options || {};        var loc = name.indexOf(":");        // order of prefix preference        // 1. in the uri option        // 2. in the prefix option        // 3. in the qualified name        // 4. from the defaultPrefix        var uri = options.uri || this.namespaces[options.prefix];        if(!uri) {            loc = name.indexOf(":");            uri = this.namespaces[name.substring(0, loc)];        }        if(!uri) {            uri = this.namespaces[this.defaultPrefix];        }        var node = this.createElementNS(uri, name);        if(options.attributes) {            this.setAttributes(node, options.attributes);        }        if(options.value) {            node.appendChild(this.createTextNode(options.value));        }        return node;    },        /**     * Method: setAttributes     * Set multiple attributes given key value pairs from an object.     *     * Parameters:     * node - {Element} An element node.     * obj - {Object || Array} An object whose properties represent attribute     *     names and values represent attribute values.  If an attribute name     *     is a qualified name ("prefix:local"), the prefix will be looked up     *     in the parsers {namespaces} object.  If the prefix is found,     *     setAttributeNS will be used instead of setAttribute.     */    setAttributes: function(node, obj) {        var value, loc, alias, uri;        for(var name in obj) {            value = obj[name].toString();            // check for qualified attribute name ("prefix:local")            uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null;            this.setAttributeNS(node, uri, name, value);        }    },    CLASS_NAME: "OpenLayers.Format.SLD.v1" });

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -