Convert from coordinates to pixels

旧巷老猫 提交于 2019-12-24 18:25:11

问题


I am implementing a rightclick context menu on my google v3 map and I need to get the pixel x and y to correctly position the menu. I get the lat and the lng, anyone have a nice solution to get the pixel x and y?

Best Regards

Henkemota


回答1:


index=x+(y*height)

x = index % width
y = index / height



回答2:


Correction to the above answer:

index=x+(y*width) 

//(not y*height ... because you're taking one full horizontal line of pixels (e.g. 1280px) and multiplying that by the number of lines (y) down the screen at which x is, then adding x to account for x pixels over in the next full line.)

x = index % width
y = index / height


来源:https://stackoverflow.com/questions/10917326/convert-from-coordinates-to-pixels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!