Reputation: 226
I want to move Point1 to the direction of Point2 on an OSM(Openstreetmap) Map in Java EE with the Vaadin Framework. The Wrapper there for the OSM (or any other Map) is called V-Leaflet.
I was thinking about to add an Offset to the numeric Lat-/Lon coordinates(for example lat: 52.3; Lon: 10.4), but my problem is Point2. I don't have any idea, how i can get the offset for point1 relative to the point2, that the point1 moves right to the direction of point2.
Maybe my approach is wrong.
Here is a little picture, to see my problem on the "Map": picture of the problem
best regards
thunder
Upvotes: 0
Views: 135
Reputation: 226
I solved it by myself, with using Vectors.
I converted point1 (a) and point2 (b) into a vector and then i'm calculating vector b - a, to get the distance.
To move the point1 (a) with direction to point2 (b), you can just calculate (c):
c = a + (distance to move, for example: 1/2) * (a - b)
best regards
thunder
Upvotes: 1