Skip to content
Snippets Groups Projects
Commit 63515a0e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

coordinates of the polygon are computed properly when the polygon cross -180...

coordinates of the polygon are computed properly when the polygon cross -180 degres (due to world map being not flat)
parent 4798eb50
No related branches found
No related tags found
3 merge requests!46912.1.0~beta.4 into master,!45912.1.0~beta.3 into master,!457Resolve "coordinates of polygon are not computed properly when polygon goes outside map"
Pipeline #6791 passed
......@@ -360,10 +360,15 @@ MapCanvas.prototype.latLngToPoint = function (latLng) {
* @returns {string}
*/
MapCanvas.prototype.pointsToString = function (points) {
var self = this;
var result = "";
for (var i = 0; i < points.length; i++) {
var point = points[i];
result += point.x.toFixed(2) + "," + point.y.toFixed(2) + ";";
var x = point.x;
if (x >= self.getOptions().width * 2) {
x -= 360 * self.pixelsPerLonDegree_ * self.zoomFactor;
}
result += x.toFixed(2) + "," + point.y.toFixed(2) + ";";
}
return result;
};
......
......@@ -47,6 +47,18 @@ describe('MapCanvas', function () {
assert.ok(result.indexOf("15") >= 0);
assert.ok(result.indexOf("17") >= 0);
});
it("exceeded values", function () {
var canvas = new MapCanvas(testDiv, {
tileSize: 256,
minZoom: 2,
height: 600,
width: 800
});
var result = canvas.pointsToString([new Point(2000, 10), new Point(12, 15)]);
assert.ok(result.indexOf("2000") === -1);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment