[OpenLayers-Commits] r7334 - trunk/openlayers/lib/OpenLayers/Layer

commits at openlayers.org commits at openlayers.org
Mon Jun 9 15:11:03 EDT 2008


Author: tschaub
Date: 2008-06-09 15:11:03 -0400 (Mon, 09 Jun 2008)
New Revision: 7334

Modified:
   trunk/openlayers/lib/OpenLayers/Layer/Text.js
Log:
The text format conditionally sets values for feature.style.graphicXOffset and graphicYOffset.  If these are not defined in parsing, we confirm that using the non-identity operator with undefined.  Later, it might make sense to confirm these values are actually numeric (see #1441). This keeps an icon.offset from inadvertently getting created with NaN values later on.  r=elemoine (closes #1571)

Modified: trunk/openlayers/lib/OpenLayers/Layer/Text.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Text.js	2008-06-09 17:18:35 UTC (rev 7333)
+++ trunk/openlayers/lib/OpenLayers/Layer/Text.js	2008-06-09 19:11:03 UTC (rev 7334)
@@ -170,9 +170,19 @@
             }        
             
             // FIXME: At the moment, we only use this if we have an 
-            // externalGraphic, because icon has no setOffset API Method.  
-            if (feature.style.graphicXOffset !== null
-                && feature.style.graphicYOffset !== null) {
+            // externalGraphic, because icon has no setOffset API Method.
+            /**
+             * FIXME FIRST!!
+             * The Text format does all sorts of parseFloating
+             * The result of a parseFloat for a bogus string is NaN.  That
+             * means the three possible values here are undefined, NaN, or a
+             * number.  The previous check was an identity check for null.  This
+             * means it was failing for all undefined or NaN.  A slightly better
+             * check is for undefined.  An even better check is to see if the
+             * value is a number (see #1441).
+             */
+            if (feature.style.graphicXOffset !== undefined
+                && feature.style.graphicYOffset !== undefined) {
                 iconOffset = new OpenLayers.Pixel(
                     feature.style.graphicXOffset, 
                     feature.style.graphicYOffset);



More information about the Commits mailing list