I am using the jxmapkit to show a map in a java frame. Now i am trying to translate a click x,y position into Lat, Long.
This is what I have so far:
public void mouseClicked(MouseEvent e)
{
Point point = e.getPoint();
JXMapViewer map = mainMap.getMainMap();
Rectangle bounds = map.getViewportBounds();
int x = (int)(point.getX() - bounds.getX());
int y = (int)(point.getY() - bounds.getY());
GeoPosition mappos = map.getTileFactory().pixelToGeo(new Point(x,y), map.getZoom());
But the bounds x and y are too big 282723 and 205680 so the translation is obviously failing.
Does Rectangle bounds = map.getViewportBounds(); work or am I doing something wrong?