I am trying to figure out how to plot WGS84 latitude/longitude points on a bitmap but cannot figure out the math required to turn lat/lon points into coordinates that would be plottable. Could anyone give me some pointers or examples on how to do this?
thanks
Colin
To obtain coordinates for a location on Android, you'll drop a pin. Tap and hold a spot on the map. You'll see a red pin appear on the map and a Dropped Pin window at the bottom. The coordinates for the pinned location appear in the Search box at the top.
Turning latitude longitude into x, y for plotting on a flat 2d surface like a bitmap is a large and complicated topic.
For general information about this see map Projections on wikipedia.
In general websites like google maps and bing solve this problem by using a mercator projection on a perfect sphere which can easily cover most of the earth (except the north/south pole) and be 'good enough' for most purposes. However, those are some big ifs and it really depends on how accurate your pictures need to be and what they need to preserve.
Unfortunately I don't know delpi well enough to provide source code but the math for mercator projections is well documented here.
If accuracy is not an issue at all and your points are 'close together', the simplest method would be to simply use a constant factor and offset to shift latitude/longitude into x and y values that fit onto your bitmap.
This might make a slightly squish your pictures in the north/south direction but in general will produce pictures much like mercator without the natural logarithms and sin/tangent calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With