I have to create a canvas that contains object with position in binding with latitude and longitude.
My canvas support element’s drag and zooming but until now I have used always standard coordinate (from 0,0)
Now I have GPS coords and all objects overlap each other because GPS coord is for example between 45°11’00’N and 45°11’60N… so is basically 1px of distance if I can’t solve this conversion… also canvas starts from 0,0 and I have always 45 pixel of white space
I can retrive minimum left and top values and recalc the size but how can center all the objects in the canvas?
Was gonna do a blog post on this at some point and may still do. But – in short – I solved this issue just by writing my own panel that understands how to position children according to the mercator projection.
Some things to know before using it:
MaxLatitudeandMaxLongitudeto whatever range is supported in your background image.You use it like this:
Here’s the code:
If I ever get around to the blog post, I’ll update this answer.