[mapguide-users] Map/Legend refresh after MgResourceService.SetResource (Fusion)

miansi AndreiSinelnikov at SierraSystems.com
Tue May 11 22:06:17 EDT 2010


Hello,

Finishing move from AJAX viewer to Fusion Viewer.

Almost :-) everything work fine but refreshing map during runtime layer
creation.

Logic:

        /// <summary>
        ///   Permanently Add Thematic Layer to Map
        /// </summary>
        /// 
        internal void AddThematicLayerToMap(ThematicLayerInfo
thematicLayerInfo)
        {
            var resourceService =
(MgResourceService)this.MgConn.CreateService(MgServiceType.ResourceService);
            var layerName = String.Format(
                "{0}-{1}-{2}", thematicLayerInfo.ThematicLayerName.Replace("
", String.Empty), thematicLayerInfo.AttributeField, Guid.NewGuid());

            var resourceId =
String.Format(this.Attributes.MgThemeSourceName, thematicLayerInfo.Network,
layerName);
            var resourseLayer = new MgResourceIdentifier(resourceId);

            resourceService.SetResource(resourseLayer, new
MgByteReader(thematicLayerInfo.LayerDefString, MgMimeType.Xml), null);

            var resourceMap = new
MgResourceIdentifier(this.Attributes.MgMapName);

            var xmlMap = Helper.GetMapXml(
                resourceService,
                resourceMap,
                resourseLayer,
                layerName,
                thematicLayerInfo.ThematicLayerName + " - " +
Utility.FormatAttributeText(thematicLayerInfo.AttributeField),
                thematicLayerInfo.Network,
                thematicLayerInfo.Network,
                true,
                null);

            resourceService.SetResource(resourceMap, new
MgByteReader(xmlMap, MgMimeType.Xml), null);
        }

Basically if I refresh the page (IE8) - I will see added layer on the legend
and on the map, but it is not happening without refresh.

In any other area of the application where I use SetResource - map and
legend gets refreshed.

As you can see I use same resource service for saving layer and map. I tried
new instance of resource service - no luck. I tried UpdateRepository -
always getting exception about wrong resourse type, I tried at the end of
method to do following logic:

            var map = new MgMap(this.MgConn);

            map.Open(this.Attributes.MapName);

           // Save map
            map.Save();

No luck...

I updated C:\Program Files
(x86)\OSGeo\MapGuide\Web\www\fusion\layers\MapGuide\MapGuideViewerApi.js to
include following method:

function Reload() {
    //var Fusion = window.top.Fusion;
    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
    if (mapWidget && mapWidget.isMapLoaded()) {
        mapWidget.reloadMap();
        mapWidget.redraw();
    }
}

And calling it at the end...


So, right now completely out of ideas... Well... As a last method I can
submit frame instead of calling Reload, but page will flash and I do not
want it.

Maybe somebody can point me in the right direction?


Thank you!

Andrei
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Map-Legend-refresh-after-MgResourceService-SetResource-Fusion-tp5039258p5039258.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list