OpenLayers OpenLayers

Changeset 6165

Show
Ignore:
Timestamp:
02/09/08 00:02:23 (1 year ago)
Author:
ahocevar
Message:

added cr5's changes, but extend the layer style before applying it to features.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/ahocevar/styleMap/examples/openmnnd.html

    r6152 r6165  
    1717 
    1818        function init(){ 
    19             OpenLayers.ProxyHost="/proxy/?url="; 
     19            OpenLayers.ProxyHost="/cgi-bin/proxy.cgi?url="; 
    2020            map = new OpenLayers.Map('map', {'maxResolution':'auto', maxExtent: new OpenLayers.Bounds(-203349.72008129774,4816309.33,1154786.8041952979,5472346.5), projection: 'EPSG:26915' } ); 
    2121            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
     
    2929            map.addLayer(wms); 
    3030 
    31             wfs = new OpenLayers.Layer.WFS("Minnesota Streams (WFS)", wfs_url, {'typename':'streams'}, {ratio:1.25, minZoomLevel:4}); 
     31            wfs = new OpenLayers.Layer.WFS("Minnesota Streams (WFS)", wfs_url, {'typename':'streams'}, {ratio:1.25, minZoomLevel:4, style: OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default'])}); 
    3232 
    3333            // preFeatureInsert can be used to set style before the feature is drawn 
    34             wfs.preFeatureInsert= function(feature) { feature.style.strokeWidth="3"; feature.style.strokeColor="blue"; 
     34            wfs.preFeatureInsert= function(feature) {  
     35              feature.style = OpenLayers.Util.extend({}, feature.layer.style); 
     36              feature.style.strokeWidth="3"; feature.style.strokeColor="blue"; 
    3537            } 
    3638            wfs.onFeatureInsert = function(feature) { 
     
    5860 
    5961            rstyle = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); 
    60             OpenLayers.Util.extend(rstyle, {'strokeColor': 'white', strokeWIdth: "4"}); 
     62            OpenLayers.Util.extend(rstyle, {'strokeColor': 'white', strokeWidth: "4"}); 
    6163            rwfs = new OpenLayers.Layer.WFS("Minnesota Roads (WFS)", wfs_url, {'typename':'roads'}, 
    6264              {ratio:1.25, minZoomLevel:7, extractAttributes: true, style:rstyle}); 
  • sandbox/ahocevar/styleMap/examples/osm-layer.html

    r6152 r6165  
    4848        } 
    4949        function style_osm_feature(feature) { 
    50             feature.style.fill = "black"
     50            feature.style = OpenLayers.Util.extend({'fill':'black'}, OpenLayers.Feature.Vector.style['default'])
    5151            if (feature.attributes.highway == "motorway") { 
    5252                feature.style.strokeColor = "blue"; 
  • sandbox/ahocevar/styleMap/examples/wfs-scribble.html

    r6152 r6165  
    3636            df.featureAdded = function(feature) { 
    3737              feature.state = OpenLayers.State.INSERT; 
    38               feature.style['strokeColor'] = "#ff0000"
     38              feature.style = OpenLayers.Util.extend({'strokeColor': '#ff0000'}, OpenLayers.Feature.Vector.style['default'])
    3939              feature.layer.drawFeature(feature); 
    4040            } 
  • sandbox/ahocevar/styleMap/lib/OpenLayers/Layer/Vector.js

    r6152 r6165  
    310310                } 
    311311 
     312            if (this.style) { 
     313                feature.style = OpenLayers.Util.extend({}, this.style); 
     314            } 
     315 
    312316            this.features.push(feature); 
    313317