How to change 1 meter to pixel distance?

后端 未结 5 2177
一个人的身影
一个人的身影 2020-12-25 09:50

When I develop an Android map application, I want to draw a circle on the map whose radius is 1 meter. As you known, I can\'t draw 1 meter directly, I should convert 1 meter

5条回答
  •  悲&欢浪女
    2020-12-25 10:18

    Three questions you got to ask 1- How big is your map 2- What is your zoom level 3- How big is your screen

    Let's make the assumption that the map has the same aspect ratio as your screen (if not then you need to worry about which way to crop (verically vs horizontally) or which way to stretch and then change y our answer to 1)

    Once you have the answer 1 and 3 you can work out the ratio between meters and pixels in the 100% zoom case, so you will have a pixels per meter

    Next you need to maintain a zoom factor (eg: zoom in double size is 200%)

    your call to draw the circle will look like this

     Canvas.draw(x,y, radius_in_meters * pixels_per_meter * zoom_factor/100);
    

提交回复
热议问题