Throw exception if Position or Zoom is set outside bounds

Topics: Feature Requests
Feb 28, 2012 at 4:12 AM

I am driving GMap from a parent WPF application. The parent application drives GMap by setting the Position and Zoom properties. The parent application has a camera model that allows the user to scroll the map off the screen as well as do unlimited zoom.

GMap internally clamps the Position to force it to stay within the bounds of the map and it clamps the zoom to stay within MinZoom and MaxZoom. And that is a probably a perfectly good design decision. But it means that the state of the GMapControl object (the value of Position and Zoom) does not match what it actually displayed on the screen. Is there a way that I can notify the parent application when the GMapControl clamps those values? A solution could be to have GMap throw an exception when one attempts to set the Position or Zoom outside the bounds. That way the value of Zoom and Position will always reflect what is shown of the screen and visa versa. And to avoid hitting that exception one would need a way of getting those bounds.

In shot my request is:

Throw exceptions if Position or Zoom is set out of bounds

Add property/properties that return bounds on Position.

Feb 28, 2012 at 6:42 AM

i don't get it exactly?

Feb 28, 2012 at 10:57 AM

If I set Position to (0 deg, 220 deg) then GMap will actually clamp this value to (0 deg, 180 deg) if I use BingMapProvider with MercatorProjection. The problem (from my point of view) is that it does so silently. If I get the Position, GMap still returns (0 deg, 220 deg) even when it is clearly rendering the map using the position (0 deg, 180 deg). And since there is no way I can tell that GMap clamps the position, I render the overlays on top at the wrong location.

I will like to be able to query the limits on Position that GMap uses internally. That way I can avoid setting a Position outside these bounds.

From an OOD point of view, I will argue that GMap should not clamp the values silently. If one sets a value outside the valid bounds, then GMap should throw ArgumentOutOfRangeException from the property setter.

Alternatively GMap should not clamp the values.

Feb 28, 2012 at 11:07 AM

..but there is no 220 degrees ;} min is -180, max is +180, i can add checking but nobody so far needed any checking

..and why do you render overlays 'on top', they are integrated anyway

Feb 28, 2012 at 11:31 AM
Edited Feb 28, 2012 at 11:45 AM

I am using GMap as a map layer in an other GIS application.

For instance your LatviaMapProvider uses the LKS92Projection that uses these bounds

55.55 <= latitude <= 58.58 and 20.22 <= longitude <= 28.28

Your Mercator projection has these boundaries on latitude

-85.05112878 <= latitude <= 85.05112878

So min and max are not always -180 and 180.


Feb 28, 2012 at 1:51 PM