Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Zoom in XampMap ?
posted

Hi , How can i set a  default zoom to my XampMap when its displayed ,

 

 

thanks

Parents
  • 2505
    Offline posted

    Hi bouhmid86,

    A sample approach to achieve this could be the following.

    XAML:
            <igMap:XamMap x:Name="map1" Loaded="map1_Loaded">
                <igMap:XamMap.Layers>
                    <igMap:MapLayer x:Name="statesLayer">
                        <igMap:MapLayer.Reader>
                            <igMap:ShapeFileReader Uri="Shapefiles/usa/usa_st" DataMapping="Name=STATE_NAME; Value=POP1997; Caption=STATE_NAME"/>
                        </igMap:MapLayer.Reader>
                    </igMap:MapLayer>
                </igMap:XamMap.Layers>
            </igMap:XamMap>

    CB:
            private void map1_Loaded(object sender, RoutedEventArgs e)
            {
                ZoomMapToRegion(3);
            }

            public void ZoomMapToRegion(double zoom)
            {
                DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1.0) };

                timer.Tick += (o, e) =>
                {
                    map1.WindowZoom = zoom;
                    ((DispatcherTimer)o).Stop();
                };

                timer.Start();
            }

    Hope that helps,
    Milana Zhileva

Reply Children