Пример #1
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession(GetKey("Selection"));
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempTable");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempLayer");
            }
        }
Пример #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MapInfo.Mapping.Map myMap = GetMapObj();
            if (Session.IsNewSession)
            {
                AppStateManager stateManager = new AppStateManager();
                stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
                MapInfo.WebControls.StateManager.PutStateManagerInSession(stateManager);

                // Add customized web tools
                // Below line will put controlModel into HttpSessionState.
                MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession();
                controlModel.Commands.Add(new AddPinPointCommand());
                controlModel.Commands.Add(new ClearPinPointCommand());
                controlModel.Commands.Add(new ModifiedRadiusSelectionCommand());

                /****** Set the initial state of the map  *************/
                // Clear up the temp layer left by other customer requests.
                if (myMap != null)
                {
                    if (myMap.Layers[SampleConstants.TempLayerAlias] != null)
                    {
                        myMap.Layers.Remove(SampleConstants.TempLayerAlias);
                    }
                }
                // Need to clean up "dirty" temp table left by other customer requests.
                MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias);
                // Need to clear the DefautlSelection.
                MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();

                // Creat a temp table and AddPintPointCommand will add features into it.
                MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias);
                // Make the table mappable
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys()));
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());

                MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
                // Create a new FeatureLayer based on the temp table, so we can see the temp table on the map.
                myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));

                // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool.
                myMap.Zoom   = new MapInfo.Geometry.Distance(25000, MapInfo.Geometry.DistanceUnit.Mile);
                myMap.Center = new MapInfo.Geometry.DPoint(27775.805792979896, -147481.33999999985);
            }

            MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
        }
Пример #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MapInfo.Mapping.Map myMap = GetMapObj();
            if(Session.IsNewSession)
            {
                AppStateManager stateManager = new AppStateManager();
                stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias;
                MapInfo.WebControls.StateManager.PutStateManagerInSession(stateManager);

                // Add customized web tools
                // Below line will put controlModel into HttpSessionState.
                MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession();
                controlModel.Commands.Add(new AddPinPointCommand());
                controlModel.Commands.Add(new ClearPinPointCommand());
                controlModel.Commands.Add(new ModifiedRadiusSelectionCommand());

                /****** Set the initial state of the map  *************/
                // Clear up the temp layer left by other customer requests.
                if(myMap != null)
                {
                    if(myMap.Layers[SampleConstants.TempLayerAlias] != null)
                    {
                        myMap.Layers.Remove(SampleConstants.TempLayerAlias);
                    }
                }
                // Need to clean up "dirty" temp table left by other customer requests.
                MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias);
                // Need to clear the DefautlSelection.
                MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();

                // Creat a temp table and AddPintPointCommand will add features into it.
                MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias);
                // Make the table mappable
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys()));
                ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());

                MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
                // Create a new FeatureLayer based on the temp table, so we can see the temp table on the map.
                myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));

                // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool.
                myMap.Zoom = new MapInfo.Geometry.Distance(25000, MapInfo.Geometry.DistanceUnit.Mile);
                myMap.Center = new MapInfo.Geometry.DPoint(27775.805792979896,-147481.33999999985);
            }

            MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState();
        }