From 4a4e7b7e07ec38f6a2d9851b982e3743dc57feb4 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sun, 21 Dec 2008 15:01:11 +0000 Subject: [PATCH] fix for KML element "fill" is unsupported, patch by rdewit, r=me, tests by me, (Closes #1724) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8532 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/KML.js | 7 ++++++- tests/Format/KML.html | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/KML.js b/lib/OpenLayers/Format/KML.js index 7aa6b3809f..68a41ce0ac 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -339,7 +339,12 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { var r = matches[4]; style["fillColor"] = "#" + r + g + b; } - + // Check is fill is disabled + var fill = this.parseProperty(styleTypeNode, "*", "fill"); + if (fill == "0") { + style["fillColor"] = "none"; + } + break; case "iconstyle": // set scale diff --git a/tests/Format/KML.html b/tests/Format/KML.html index 92379ede00..c16bbb7c78 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -5,6 +5,7 @@ var test_content = 'OpenLayers exportVector geometries from OpenLayersOpenLayers.Feature.Vector_344A KLM Polygon5.001370157823406,49.26855713824488 8.214706453896161,49.630662409673505 8.397385910100951,48.45172350357396 5.001370157823406,49.26855713824488OpenLayers.Feature.Vector_402A KML LineString5.838523393080493,49.74814616928052 5.787079558782349,48.410795432216574 8.91427702008381,49.28932499608202OpenLayers.Feature.Vector_451A KML Point6.985073041685488,49.8682250149058SF Marina Harbor MasterKML MultiGeometry-122.4425587930444,37.80666418607323 -122.4428379594768,37.80663578323093-122.4425509770566,37.80662588061205 -122.4428340530617,37.8065999493009'; var test_style = ' -112,36 -113,37 '; + var test_style_fill = ' -112,36 -113,37 '; var test_nl = ' http://maker.geocommons.com/maps/1717/overlays/0 '; function test_Format_KML_constructor(t) { @@ -134,6 +135,14 @@ var features = f.read(test_style); t.ok(features[0].style == undefined, "KML Feature has no style with extractStyle false"); } + function test_Format_KML_extractStyleFill(t) { + t.plan(2); + var f = new OpenLayers.Format.KML({extractStyles: true}); + var features = f.read(test_style); + t.eq(features[0].style.fillColor, "#ff0000", "default fill is set"); + var features = f.read(test_style_fill); + t.eq(features[0].style.fillColor, "none", "KML Feature has none fill"); + }