Looking for solution to display active region in Map center

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
User avatar
webdirekt
Posts: 28
Joined: Wed Jul 15, 2015 10:18 am

Looking for solution to display active region in Map center

Post by webdirekt »

- We have the list of Points (i.e. X and Y coordinates) and Geometry data with respect to list of zip codes.
- Based on result of Geometry data; we have added BaseLayer in the map using the tile renderer which is implemented from ITiledProvider interface (Ptv.XServer.Controls.Map.Layers.Tiled).
- We have set the map control envelope using the list of Points (i.e. X and Y coordinates).

Code: Select all

wpfMap.SetEnvelope(new MapRectangle(pointList), "OG_GEODECIMAL");
-- wpfMap: ptv wpf map control.
-- pointList: list of Points (i.e. X and Y coordinates).
-- "OG_GEODECIMAL": Point format
Issue:
Active region is displayed in the center of the map as expected but some part of the region is still out side the map.
Find "ActiveRegionActualResult.png" which shows the current display of Map
Find "ActiveRegionExcpectedResult.png" which we want to display the Map in our App

Solutions tried:
We tried to decrease the zoom level of map programmatically as mentioned below, but its not working.
Option 1:

Code: Select all

ptvMap.Zoom = ptvMap.Zoom - 1;
Option 2:

Code: Select all

ptvMap.ZoomLevel = ptvMap.ZoomLevel - 1;
Attachments
ActiveRegionExcpectedResult.png
ActiveRegionExcpectedResult.png
ActiveRegionActualResult.png
ActiveRegionActualResult.png
User avatar
Oliver Heilig
Posts: 154
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: Looking for solution to display active region in Map cen

Post by Oliver Heilig »

Hi,

are you sure you're getting you points right? It works for me as excpected.
envelope.png
How i verified this:
[*] Downloaded the project https://github.com/ptv-logistics/SharpMap.Widgets
[*] Set SharpMap.Win as startup project
[*] at Form1::SelectedRegions_CollectionChanged change like below

Note: The SetEnvelope method set the map section to fit the envelope exactly longitudal or latitulal, depending on the ration of the window/envelope. You can use the MapRect.Inflate() method to increase the size to get a buffer.

Oli

Code: Select all

        private void SelectedRegions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if(this.selectedRegions.Count == 0)
            {
                propertyGrid1.SelectedObject = null;
                return;
            }

            var selectedItem = selectedRegions[0];

            // test: set the map envelope to fit the selected item;
            // ... using Ptv.XServer.Controls.Map;
            // ... using GeoAPI.Geometries;

            // set the maprectangle from sharpmap geomatry
            var envelope = selectedItem.Geometry.EnvelopeInternal;
            var rect = new MapRectangle(
                new System.Windows.Point(envelope.Right(), envelope.Top()),
                new System.Windows.Point(envelope.Left(), envelope.Bottom()));
            // inflate by 20%
            rect.Inflate(1.2);

            this.formsMap1.SetEnvelope(rect);

            // ....

            // dump all attributes
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
User avatar
webdirekt
Posts: 28
Joined: Wed Jul 15, 2015 10:18 am

Re: Looking for solution to display active region in Map cen

Post by webdirekt »

Thank you very much. It works perfectly for us and solved the issue. :)
Post Reply