I managed to fix this issue by checking if the line crosses the meridian, if it does. i draw a "artificial" line between the last point before the crossing, and tie it up to the border (180) - And then create a second "fake" line from -180 and up to the point where the original point should have ended. After that it continues as normal until it hits the meridian again.
Some key code from my script.
var startPoint = new OpenLayers.Geometry.Point(points[temp_index].x,points[temp_index].y);
if (typeof points[index] === 'undefined') { continue;}
var endPoint = new OpenLayers.Geometry.Point(points[index].x,points[index].y);
if (Math.abs(startPoint.x-endPoint.x) > 180) {
//Line crosses the meridian.
//Find the middle Y so that we dont get to much of a gap in the middle
var midY = (startPoint.y + endPoint.y) / 2
var temp_endpoint = new OpenLayers.Geometry.Point(startPoint.x,midY);
var temp_startpoint = new OpenLayers.Geometry.Point(startPoint.x,midY);
if (startPoint.x < endPoint.x) {
temp_endpoint.x = -180;
temp_startpoint.x = 180;
} else {
temp_endpoint.x = 180;
temp_startpoint.x = -180;
}
And then after transforming the points e.e add it to a vector layer.
features.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([startPoint,temp_endpoint])));
features.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([temp_startpoint,endPoint])));
Note: My function recieves a list of points which i tie up to a linestring.
I hope this helps anyone else that are experiencing this issue.
projection: "EPSG:900913", displayProjection: new OpenLayers.Projection("EPSG:4326")