OpenLayers OpenLayers

Changeset 7607

Show
Ignore:
Timestamp:
07/30/08 10:53:24 (4 months ago)
Author:
crschmidt
Message:

Fix for Inline KML styles extracted even though extractStyles is false,
from Edgemaster. r=me, tests=me, (Closes #1576)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Format/KML.js

    r7339 r7607  
    542542                } 
    543543 
    544                 // Make sure that <Style> nodes within a placemark are  
    545                 // processed as well 
    546                 var inlineStyleNode = this.getElementsByTagNameNS(featureNode, 
    547                                                        "*", 
    548                                                        "Style")[0]; 
    549                 if (inlineStyleNode) { 
    550                     var inlineStyle= this.parseStyle(inlineStyleNode); 
    551                     if (inlineStyle) { 
    552                         feature.style = OpenLayers.Util.extend( 
    553                             feature.style, inlineStyle 
    554                         ); 
     544                if (this.extractStyles) { 
     545                    // Make sure that <Style> nodes within a placemark are  
     546                    // processed as well 
     547                    var inlineStyleNode = this.getElementsByTagNameNS(featureNode, 
     548                                                        "*", 
     549                                                        "Style")[0]; 
     550                    if (inlineStyleNode) { 
     551                        var inlineStyle= this.parseStyle(inlineStyleNode); 
     552                        if (inlineStyle) { 
     553                            feature.style = OpenLayers.Util.extend( 
     554                                feature.style, inlineStyle 
     555                            ); 
     556                        } 
    555557                    } 
    556558                } 
  • trunk/openlayers/tests/Format/KML.html

    r6719 r7607  
    55 
    66    var test_content = '<kml xmlns="http://earth.google.com/kml/2.0"><Folder><name>OpenLayers export</name><description>Vector geometries from OpenLayers</description><Placemark id="KML.Polygon"><name>OpenLayers.Feature.Vector_344</name><description>A KLM Polygon</description><Polygon><outerBoundaryIs><LinearRing><coordinates>5.001370157823406,49.26855713824488 8.214706453896161,49.630662409673505 8.397385910100951,48.45172350357396 5.001370157823406,49.26855713824488</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark id="KML.LineString"><name>OpenLayers.Feature.Vector_402</name><description>A KML LineString</description><LineString><coordinates>5.838523393080493,49.74814616928052 5.787079558782349,48.410795432216574 8.91427702008381,49.28932499608202</coordinates></LineString></Placemark><Placemark id="KML.Point"><name>OpenLayers.Feature.Vector_451</name><description>A KML Point</description><Point><coordinates>6.985073041685488,49.8682250149058</coordinates></Point></Placemark><Placemark id="KML.MultiGeometry"><name>SF Marina Harbor Master</name><description>KML MultiGeometry</description><MultiGeometry><LineString><coordinates>-122.4425587930444,37.80666418607323 -122.4428379594768,37.80663578323093</coordinates></LineString><LineString><coordinates>-122.4425509770566,37.80662588061205 -122.4428340530617,37.8065999493009</coordinates></LineString></MultiGeometry></Placemark></Folder></kml>'; 
     7    var test_style = '<kml xmlns="http://earth.google.com/kml/2.0"> <Placemark>    <Style> <LineStyle> <color>870000ff</color> <width>10</width> </LineStyle> </Style>  <LineString> <coordinates> -112,36 -113,37 </coordinates> </LineString> </Placemark></kml>'; 
    78 
    89    function test_Format_KML_constructor(t) {  
     
    118119 
    119120    } 
     121    function test_Format_KML_extractStyle(t) { 
     122        t.plan(1); 
     123        var f = new OpenLayers.Format.KML(); 
     124        var features = f.read(test_style);     
     125        t.ok(features[0].style == undefined, "KML Feature has no style with extractStyle false");         
     126    }  
    120127 
    121128    </script>