# How to mark a particular point in MapPanel?

There is a component called MapPanel, which displays OpenStreetMaps.

I want to mark some places on the displayed map, without changing the underlying map. Those marked places are identified by latitude and longitude.

In order to implement this, I wrote following class, which should convert latitude and longitude to pixel coordinates.

``````@Override
public Point convert(double aLatitude, double aLongitude, Rectangle bounds) {

final Point pointInMapUnits = mapPanel.computePosition(new Point.Double(aLatitude, aLongitude));

Point mapCenter = mapPanel.getCenterPosition();
Dimension mapSize = mapPanel.getMapSize();

final Rectangle panelSize = bounds;
final Point2D.Double panelCenter = new Point.Double(panelSize.x + panelSize.getWidth()/2,
panelSize.y + panelSize.getHeight()/2);

final double ourObjectXFromMapCenterInMapUnits = pointInMapUnits.getX() - mapCenter.getX();
final double ourObjectYFromMapCenterInMapUnits = pointInMapUnits.getY() - mapCenter.getY();

final double ourObjectXFromMapCenterInPixels = convertToPixelsX(ourObjectXFromMapCenterInMapUnits, panelSize,
mapSize, mapPanel.getZoom());
final double ourObjectYFromMapCenterInPixels = convertToPixelsY(ourObjectYFromMapCenterInMapUnits, panelSize,
mapSize,mapPanel.getZoom());

final Point result = new Point((int)(panelCenter.getX() + ourObjectXFromMapCenterInPixels),
(int)(panelCenter.getY() + ourObjectYFromMapCenterInPixels));

return result;
}
``````

But it doesn't work as following screenshots illustrate.

Step 1: Map is centered at the point in question (132.18381, 43.35514). That place is marked by a red dot.

Step 2: Now we scroll the map so that the marked place is located to the left of the position in step 1.

The blue dot shows where the red dot should be.

Step 3: Now we scroll the map so that the marked place is at the top.

Again the blue dot shows the expected position of the red dot.

Here's a video of the process.

You can find the code here.

How can I change it, in order for the dot to always be displayed at the point (132.18381, 43.35514) ?

I added a new method to the `MapPanel` which does what you want. The method is called `getScreenCoordinates`. I just moved the `MapPanel` to github, so you need to get the latest version from
``````public Point convert(double aLatitude, double aLongitude, Rectangle bounds) {