[mapguide-users] Re: How to change Existing Max scale for a layer

SriRam007 binod_tripathy at yahoo.co.in
Mon Mar 1 03:46:30 EST 2010


        Utility.InitializeWebTier(Request);
        string myLayerName = ddlLayerForScale.SelectedItem.Text.ToString();
        MgUserInformation userInfo = new
MgUserInformation(Session["ID"].ToString());
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgResourceService resourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
        MgMap map = new MgMap();
        map.Open(resourceService, "Sheboygan");
        MgLayerCollection layers = map.GetLayers();
        ArrayList layerNames = new ArrayList();
        MgLayer layer = Utility.GetLayerByName(map, myLayerName);
        string s = layer.GetLayerDefinition().ToString();

        MgResourceIdentifier resId = new
MgResourceIdentifier(layer.GetFeatureSourceId());
        MgResourceIdentifier layerDefResId = layer.GetLayerDefinition();
        MgByteReader byteReader =
resourceService.GetResourceContent(layerDefResId);

        string byteReaderStr = byteReader.ToString();

        ArrayList ReplaceValue = new ArrayList();
        //ReplaceValue = ViewState["scaleRanges"] as ArrayList;

        ReplaceValue = GetModifiedscaleValuefromGrid();
        bool Validate = ValidateScaleValues(ReplaceValue);
        if (Validate == true)
        {
            string layerDefinition = ReplaceScaleNodeValue(byteReaderStr,
ReplaceValue);
            String uniqueName = this.MakeUniqueLayerName(map, myLayerName);
            MgResourceIdentifier layerResId = new
MgResourceIdentifier("Session:" + Session["ID"].ToString() + "//" +
uniqueName + ".LayerDefinition");
            MgByteReader reader = new MgByteReader(layerDefinition,
"text/xml");
            resourceService.SetResource(layerResId, new
MgByteReader(layerDefinition, "text/xml"), null);

            MgLayer newLayer = new MgLayer(layerResId, resourceService);
            newLayer.SetName(uniqueName);
            newLayer.SetLegendLabel(layer.GetLegendLabel());
            newLayer.SetDisplayInLegend(layer.GetDisplayInLegend());
            newLayer.SetVisible(true);
            newLayer.SetSelectable(layer.GetSelectable());
            layers.Insert(layers.IndexOf(layer), newLayer);
            newLayer.ForceRefresh();
            map.Save(resourceService);//Not showing error but not working
also.
            //map.Save(resourceService, layerResId);//showing error
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"RefreshMap", "parent.parent.mapFrame.Refresh();", true);
                    }
        else
        {
            lblerror.Text = "Please enter correct scale ranges.";
        }


where i need to change please guide me.
thanks

-- 
View this message in context: http://n2.nabble.com/How-to-change-Existing-Max-scale-for-a-layer-tp4637661p4653107.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list