ThinkGeo.com    |     Blog    |     Wiki    |     Support

Centering map at a given position - Unhandled Exception: System.ArgumentOutOfRangeException: The input double value is out of range. Parameter name: percentage

What is the required way to do this this ?

I am calling WpfMap.ZoomIntoCenterAt (100, centerPoint). I have also tried the ZoomOutToCenter API with similar arguments.

Guess the first question is what does the percentage argument represent and what is the allowed range. If I use a percentage of 10, map does not appear to zoom into desired center position after a refresh.

I am running the point through an appropriate projection.

Effect is presented below:

What am I missing?

Hi Klaus,

The valid valud for percent should be: 0 < percent < 100

But please notice our map have the snap feature, if your percent value is too small, the map won’t zoom because the snap to nearest level works.

And it looks your render result have some problem, does that because the projection?

Regards,

Ethan

It may be a projection problem but I’ll need confirmation.

I am establishing the projection of my feature layers based on the following:

var projection = new Proj4Projection
            {
                // Set both internal and external projection same for now..
                InternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString(),
                ExternalProjectionParametersString =   Proj4Projection.GetEpsgParametersString("3857")
            };

The external string is based on the projection used by the OsmWorldMapStreetLayer.

Based on the above, the current projection as these properties:

ExternalProjectionParametersString = “+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs”

InternalProjectionParametersString = “+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs”

With the above strings, this line of code:

var bbox = projection.ConvertToExternalProjection(new RectangleShape(-180, 90, 180, -90));

Results to a bbox of

bbox = {-3.14159265341526,1.57079632662036,3.14159265341526,-1.57079632662036}

Which does not appear correct.

Hi Klaus,

I think your code have some problem.

Because when InternalProjection equal 4326 and ExternalProjection equal 3857, the result of projection.ConvertToExternalProjection(new RectangleShape(-180, 90, 180, -90)) should equal {-61364715.8090785,43988480.2683944,61364715.8090785,-43988484.7436007} but not your result.

And the result looks like:

You can try my sample here, if I missed anything, you can modify the sample and upload it again, so I will help you find the reason.

9566.zip (101.5 KB)

Regards,

Ethan