ClemensFischer / XAML-Map-Control

XAML Map Control Library
Microsoft Public License
203 stars 59 forks source link

How to calculate units per meter #50

Closed qxd4869 closed 4 years ago

qxd4869 commented 4 years ago

Good morning, In MapProjection.cs, there is a block of codes:

/// <summary /// Gets the map scale at the specified Location as viewport coordinate units per meter (px/m). /// public virtual Vector GetMapScale(Location location) { return new Vector(ViewportScale, ViewportScale); }

How can I get ground resolution of WMS from this block of codes?

ClemensFischer commented 4 years ago

Please define "ground resolution of WMS".

gis-eastgate commented 4 years ago

Hello Clemens, With a same question, i using your library, it is pretty good and easy to setup. I have a application that have two layer: map control and drawer layer. with use google map, i can set the drawer layer ground resolution by the formula:

distortedFactor = Math.Cos(latitude * Math.PI / 180);
groudResolution = distortedFactor * 40075016 / ((uint)TILE_SIZE << zoomLevel);

but when i try to use the WMS, the formula is not right, it make the point, the lane, circle i draw on the drawer-layer is diffrerent when switch to google map.

I try with your map, if i use the WMS (Weibaden city). the zoom measure is changed. and scale is changed, but how can i change the above drawer-layer follow the map layer?

Many thanks.

ClemensFischer commented 4 years ago

That formula is for the web mercator projection. Do you use that projection with the WMS?

In order to put drawings on top of the map, use the coordinate transformation methods from the MapProjection class, not anything else.