Several threads show how to calculate the distance between two lat-lon addresses. eg here.
I want something similar but different: distance in km between point A and point B on the x axis, positive if B is to the east of A and neg if it’s to the west.
The y-delta is relatively easy, because 1deg is always ~111km (right?)
Does anyone know how I can calculate this for the x-delta?
If I interpret your question correctly, you most likely want “how far do I need to go east (or west) along my current latitude to reach the same longitude as the other point?”.
Be aware that the answer will be slightly different depending on whether you start from A or B if their latitudes are different. Be also aware that it is subtly different from “how far do I need to walk to reach the same longitude as the other point”, since this will follow a great circle not exactly due east (or west). (Extreme case: consider antipodal points on the equator)
But what you want to know is: on a sphere, the distance between longitudes scales with the cosine of latitude. X-delta = longitude-delta * cos(latitude) * 111km/deg
The points are artificially on the same latitude: I have (say) 10 locations in Some City. I want to know the offset, in km, of each location from the node [place=city][name=Some City], for X and Y separately.