I think what you want is scale = 1300000/range
You might have to fiddle with the 1300000 a bit.
Hi,
I've written a PHP script for plotting points on a map. Among other variables, the script accepts a lat/long and range. The range is in nautical miles and is represented by an integer. Currently I have limited the allowable range scale from 1 to 1000.
The map is of the entire world and needs to be presented centred on the lat/long and zoomed in to an appropriate scale based on the range. The range is represented as a circle on the map with the passed lat/long as the centre. The circle should fill the map top to bottom.
My problem lies in calculating a figure that is used to draw the map zoomed in appropriately based on the range. I don't have a clue how to calculate it as it is not linear. Currently I am using simple comparisons of the range value and assigning the "scale" a fixed value. This is far from ideal because I have to come up with this fixed value by trial and error and plug it in for a sufficient number of possible ranges. I'd like it to be a formula of course where scale = something based on range.
Some of the fixed values I'm currently using are:
1 nm = 1300000
2 nm = 630000
3 nm = 400000
4 nm = 320000
24 nm = 50000
49 nm = 27000
100 nm = 13000
1000 nm = 1300
Any help is appreciated as I am out of my depth here.
Thanks,
Doug