seems to work fine If the map is roughly street/city level, uses a

mercator projection (as

openstreetmap.org seems to), and isn't too close to the poles, linear interpolation may be accurate enough. Assuming the following:

TL = lat/lon of top left corner BR = lat/lon of bottom right corner P = lat/lon of the point you want to locate on the map (w,h) = width and height of the map you have (pixels?) the origin of the map image, (0,0), is at its top-left corner

code :

```
x = w * (P.lon - TL.lon) / (BR.lon - TL.lon)
y = h * (P.lat - TL.lat) / (BR.lat - TL.lat)
```

```
Y = k * ln((1 + sin(P.lat)) / (1 - sin(P.lat)))
```

```
k = h / (ln((1 + sin(TL.lat)) / (1 - sin(TL.lat))) - ln((1 + sin(BR.lat)) / (1 - sin(BR.lat))))
```

```
Y(TL.lat) = k * ln((1 + sin(TL.lat)) / (1 - sin(TL.lat)))
Y(P.lat) = k * ln((1 + sin(P.lat )) / (1 - sin(P.lat )))
y(P.lat) = -(Y(P.lat) - Y(TL.lat))
```

```
x = w * (P.lon - TL.lon) / (BR.lon - TL.lon) // like before
y = -(Y(P.lat) - Y(TL.lat)) // where Y(anything) depends just on h, TL.lat and BR.lat
```