0

(不使用投影库)我知道地图的中心点,(-37.500,175.500).zoom (13) 大小。400x400px,这是一个墨卡托投影(标准谷歌地图)。它用作 400x400 像素画布上的背景图像。我如何计算出这张地图的界限。

4

1 回答 1

0

假设您使用中心坐标订购地图,
Zoom = 13 //google maps zoom level (1-18etc) screenwidth
=400(pixels) //地图宽度
Latctr = -37.450 //地图中间纬度
Longctr = 170.250 //地图中间的经度
1/ Lengthlat = 111111 // 1 度纬度的长度以米为单位
2/ Lengthlong = cos lengthlat * 111111 // 1 度经度的长度
3/ Ratiolengths == lengthlat/lengthlong
4/ LongitudeValueAdjust = ((lengthlat/(2^zoom)/(screenwidth*2)* RatioLengths
5/ LatitudeValueAdjust = (lengthlat/(2^zoom)/(screenwidth*2)
6/ Northwestlat = latctr + latitudeValueAdjust
7/ Northwestlong = longctr -longValueAdjust
8/ Southeastlat = latctr - LatValueAdjust
9/ Southeastlong = longctr + longValueAdjust
现在你知道地图角落的坐标了

Plotting lat lng to canvas/screen x,y  
//This is not a mercator projection, works fine for zooms > 9
Assumes 0,0 is the top left hand corner of the canvas  
lattodraw // Latitude value of the coordinate we wish to convert  
longtodraw // Longitude value of the coordinate we wish to convert  
1/Latplot = canavsheight /(southeastlat-northwestlat) * lattodraw-northwestlat  
2/Longplot = canvaswidth /(southeastlong-northwestlong) * longtodraw-northwestlong  
3/Draw pixel at latplot,longplot  
于 2013-03-19T04:21:42.513 回答