Calculate distance between points before add it into the layer