c# - MapControl map size (pixels) -


this article describes how total map size in pixels depending on actual zoom level.

the formula should be:

map width = map height = 256 * 2^level pixels

unfortunately doesn't seem work mapcontrol universal apps. first thing is, zoomlevel property of type double not integer (as needed in sample in article). whole number zoomlevel of i.e. 4.0 (int --> 4) formula doesn't work.

now, tried map size in pixel of mapcontrol.getoffsetfromlocation method:

    private double getmapsize()     {         point pw, pe;          mymap.getoffsetfromlocation(new geopoint(new basicgeoposition()             { longitude = -90, latitude = 0 }), out pw);         mymap.getoffsetfromlocation(new geopoint(new basicgeoposition()             { longitude = 90, latitude = 0 }), out pe);          return (pe.x - pw.x) * 2;     } 

this works discrepancy of pixels, issue not important.

i on surface pro 3 following results (zoomlevel 4.0):

surface screen (scale 1.5): 3654px

surface external screen (scale 1.0): 3274px

none of these results 4096px described in article. results correct , can work that. me it's workaround , if zoomlevel higher approx 13 getoffsetfromlocation method returns -1 pe.x , pw.x (for -90 , 90). nearer longitudes actual center works. seems getoffsetfromlocation has maximum of distance. need use nearer longitude values when having higher zoomlevel.

that not clear solution. question is: is there save method exact map size in pixels uwp mapcontrol?

thanks!

maas

the article referencing written years ago , basis map tiling system in of bing maps controls. however, tiling system , not displayed map. uwp control modifies how renders align pixel density of screen nice , clear. why seeing discrepancies between expected map pixel size when using getoffsetfromlocation. believe uwp controls base pixel density used calculations 128. surface pro 3 has pixel density of 216.33. bit of math , taking consideration 1.5 scaling, see (128*1.5)/216.33*4096 = 3635 lot closer values calculating using method. in mind, estimate pixel density of external screen 4096/3274*128 = 160.

as for:

map width = map height = 256 * 2^zoom; 

this works doubles too. old bing maps silverlight control allowed double zoom levels , worked fine when doing pixel calculations.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -