If you want to find a distance, you can just use existing services, e.g. Google Maps: see here.
If you want to measure distance in a plane (2D) or in spaced (3D), then you can use vector arithmetics. See an example here.
If you want to create a program that actually calculates the real distance of real locations, then it's quite a complex task. You need to have access to a service with real-life data (Google Maps probably), gain access to this service, make queries regarding locations then calculate the distance based on the returned data. Maybe Google Maps offers API to ask for distances.