TheUnknown
TheUnknown

Reputation: 47

Turning longitude and latitude to a Point

So im using JMapViewer and on this map i have some mapmarkers with a certain longitude and latitude

So to insert a text field next to this certain mapmarker i need to turn the longitude and latitude into a Point with X and Y to provide it to the setBound of the label.

And thanks !

Note that i need to do this so that if i moved the map the text moves with the map so when the map marker disappears the text disappears

Upvotes: 0

Views: 515

Answers (2)

trashgod
trashgod

Reputation: 205785

JMapViewer has several variations of getMapPosition() that return a Point given the geodetic coordinates. You can see how the method is used in paintMarker(), called by paintComponent(). See OsmMercator for ellipsoid and projection details.

Upvotes: 1

Steve Kuo
Steve Kuo

Reputation: 63054

You need to convert angular coordinates (lat, lon) to Cartesian coordinates (x, y). Take a look at GeoTools' GeodeticCalculator. In particular use an azimuth of 0 and 90 degrees to compute the horizontal and vertical distance from the origin of your Cartesian map.

Upvotes: 0

Related Questions