I am trying to p开发者_如何学JAVAlot cities on a windows form using their lat longs, i cannot convert them to pixels, can any one help with the right code. I kept a map image as background to the window such that cities appear at correct place. So size of the window is the major resource for me to plot. Thankyou
Calculate the lat-lon of the four corners of the form. Then using the form size and the difference between the lat-lon, you can get a factor to multiply by to get the location in the form.
For example, if the form's left side is at longitude -125, and the right side is -65, the width of the form in degrees is 60. If the actual width (me.width) of the form is 800, you would multiple the longitude of a city by 800 / 60 , or 13.33, minus the left longitude (-125). So Denver, at 105 West longitude, would be located at 20 * 13.33 or 267 in the form.
Do the same thing for the latitude (Y value).
精彩评论