2013-03-10 92 views

回答

0

假定您使用中心坐标订购一个地图,
变焦= 13 //谷歌地图缩放级别(1-18etc)
屏幕宽度= 400(像素)//地图的宽度
Latctr = -37.450 //地图的中间
Longctr = 170.250 //经度地图的中间
1/Lengthlat在1度纬度
2/Lengthlong = COS lengthlat * 111111 //长度的米= 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