diff --git a/lib/OpenLayers/Format/EncodedPolyline.js b/lib/OpenLayers/Format/EncodedPolyline.js index 60925a2604..e10e8b27e3 100644 --- a/lib/OpenLayers/Format/EncodedPolyline.js +++ b/lib/OpenLayers/Format/EncodedPolyline.js @@ -103,7 +103,7 @@ OpenLayers.Format.EncodedPolyline = OpenLayers.Class(OpenLayers.Format, { * coordinates. */ decode: function(encoded, dims, opt_factor) { - var factor = opt_factor || 1; + var factor = opt_factor || 1e5; var flatPoints = this.decodeDeltas(encoded, dims, factor); var flatPointsLength = flatPoints.length; @@ -179,7 +179,7 @@ OpenLayers.Format.EncodedPolyline = OpenLayers.Class(OpenLayers.Format, { * {String} An encoded string */ encode: function (points, dims, opt_factor) { - var factor = opt_factor || 1; + var factor = opt_factor || 1e5; var flatPoints = []; var pointsLength = points.length; diff --git a/tests/Format/EncodedPolyline.html b/tests/Format/EncodedPolyline.html index 65624a1434..14663479b8 100644 --- a/tests/Format/EncodedPolyline.html +++ b/tests/Format/EncodedPolyline.html @@ -106,8 +106,8 @@ for (i in decodedPoints) { var point = basePoints[i]; var decodedPoint = decodedPoints[i]; - t.eq(point[0], decodedPoint[0]); - t.eq(point[1], decodedPoint[1]); + t.eq(parseInt(decodedPoint[0] * 1e5), point[0]); + t.eq(parseInt(decodedPoint[1] * 1e5), point[1]); } } @@ -141,7 +141,7 @@ var format = new OpenLayers.Format.EncodedPolyline(); - t.eq(format.encode(basePoints, 2), encoded); + t.eq(format.encode(basePoints, 2, 1), encoded); } function test_encodeDeltas_returns_expected_value(t) {