I'm a beginer with OL, but I need to solve this problem...
I want to get this array to my map . Thaks for help! ;)
Segments of my array ces:
["1192.4692,1107.0745","1190.5201,1107.0029","1190.5201,1101.8436","1190.5201,1098.0733", "1192.4162,1097.9464"]
var LineSource = new ol.source.Vector({
projection: 'EPSG:3857',
format: new ol.format.Feature(LineFeat)
});
var LineFeat = new ol.Feature( {
name: "krLine",
geometry: new ol.geom.MultiLineString(ces), });
LineSource.addFeature( LineFeat );
var krLineLayer = new ol.layer.Vector({
source: LineSource,
projection: 'EPSG:3857',
});
And here is my map:
var map = new ol.Map({
layers: [
krLineLayer,
],
target: 'map',
controls: [
new ol.control.ScaleLine(),
new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(3),
})
],
view: mapView
});
Here is a SOLUTION by @Mikelis and an Example, how I get Lines into my map:
var elem;
var arr2 = [];
for (var i=0; i<ces.length; i++){
elem = ces[i].split(",");
arr2.push([parseFloat(elem[0]), parseFloat(elem[1])]);
}
console.log(arr2);
var layerLines = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({
geometry: new ol.geom.LineString(arr2),
name: 'Line',
projection: 'EPSG:3857'
})]
}),
});