From c1f994583832789f027f8868b44f2094049e32b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Wed, 27 Jan 2010 14:05:37 +0000 Subject: [PATCH] Extract the kml outline attribute. r=pgiraud (closes #2412) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9974 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 e45ae08dc5..19c04ef51e 100644 --- a/lib/OpenLayers/Format/KML.js +++ b/lib/OpenLayers/Format/KML.js @@ -340,11 +340,16 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, { var r = matches[4]; style["fillColor"] = "#" + r + g + b; } - // Check is fill is disabled + // Check if fill is disabled var fill = this.parseProperty(styleTypeNode, "*", "fill"); if (fill == "0") { style["fillColor"] = "none"; } + // Check if outline is disabled + var outline = this.parseProperty(styleTypeNode, "*", "outline"); + if (outline == "0") { + style["strokeWidth"] = "0"; + } break; case "iconstyle": diff --git a/tests/Format/KML.html b/tests/Format/KML.html index cea45f7de1..0e65d24a70 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -6,6 +6,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_style_outline = ' -112,36 -113,37 '; var test_nl = ' http://maker.geocommons.com/maps/1717/overlays/0 '; function test_Format_KML_constructor(t) { @@ -143,6 +144,14 @@ var features = f.read(test_style_fill); t.eq(features[0].style.fillColor, "none", "KML Feature has none fill"); } + function test_Format_KML_extractStyleOutline(t) { + t.plan(2); + var f = new OpenLayers.Format.KML({extractStyles: true}); + var features = f.read(test_style); + t.eq(features[0].style.strokeWidth, "10", "default stroke is set"); + var features = f.read(test_style_outline); + t.eq(features[0].style.strokeWidth, "0", "KML Feature has no outline"); + } function test_Format_KML_getStyle(t) { t.plan(1); var style = {t: true};