Hello my dear friends.
I have a Vue data variable set up like this:
var comp=
{
data()
{
return{
polygonString:""
}
}
}
The issue I am facing is that when trying to update the 'polygonString' inside the 'modifyend' method, it remains blank when checked with console.log() outside the method:
methods:{
addCoordinate(){
modify.on('modifyend', function (evt) {
var flat_coords;
var modified_coords = [];
evt.features.forEach(function (feature) {
flat_coords = feature.getGeometry().getCoordinates();
for (var i in flat_coords)
{
var flat_coord = flat_coords[i];
for(var coord_array in flat_coord)
{
var lat_lng = flat_coord[coord_array];
var transformed_coords = ol.proj.transform(lat_lng,'EPSG:3857','EPSG:4326');
modified_coords.push(transformed_coords.toString().replace(",", " "));
}
}
});
this.polygonString = modified_coords.toString().replaceAll(",", ", ");
});
console.log("UPDATED POLYGON STRING:", this.polygonString);
}
}