[mapguide-users] Reloading runtime map

Hidekazu Shimaji hshimaji at ybb.ne.jp
Sat Mar 17 12:23:29 EDT 2007


Sorry, I misread your mail.
Then, why don't you craete a new MgMap object, and overwrite 
the existing Map object in the session respository?

--- code start
//open a run-time map
MgMap map = new MgMap();
map.Open(resourceService, mapId.GetName());
//get its session repository path
MgResourceIdentifier sessionMapId = map.GetResourceId();
//create a new map
map.Create(resourceService, mapId, mapId.GetName());
//overwrite the run-time map in the new map
map.Save(resourceService, sessionMapId);
//refresh using javascript
--- code end

Hidekazu

--- Jim O'Leary <joleary.public at gmail.com> wrote:

> 
> Yes, I have seen the Developers Guide sample. However, that code only saves
> the layer to the repository. By accessing the XML in the map definition, I
> can permanently attach the layer to the map, as well as create the group.
> You cannot attach a layer to the map using the runtime map. Thus the runtime
> map is not in synch with the repository map, so I need to update the map. 
> 
> parent.parent.Refresh()
> 
> does not display the new group or layer the properties pane, and 
> 
> parent.parent.mapFrame.location.reload(true)
> 
> causes the map frame to lose references to the script frame, resulting in
> the "freed object" error. Is there another way to update the runtime map?
> 
> 
> 
> Hidekazu Shimaji wrote:
> > 
> > Hi,
> > 
> > You should use the MgMap object, not the SetResource function.
> > Like this:
> > 
> > --- code start
> > //open the run-time map
> > MgMap map = new MgMap();
> > map.Open(resourceService, "MapName"); //ex)showing "MapName.MapDefinition"
> > //create a MgLayer object from a new layer resource
> > MgResourceIdentifier newLayerId = new
> > MgResourceIdentifier("Library://....LayerDefinition");
> > MgLayer layer = new MgLayer(newLayerId, resourceService);
> > layer.SetDisplayInLegend(true);
> > layer.SetLegendLabel("NewLayer");
> > layer.SetName("LayerName");
> > layer.SetSelectable(true);
> > layer.SetVisible(true);
> > layer.ForceRefresh();
> > //get a layer collection from the map, and add the new layer to a map
> > MgLayerCollection layers = map.GetLayers();
> > layers.Add(layer);
> > //save the map
> > map.Save(resourceService);
> > --- code end
> > 
> > Php code is available in "the Developer's Guide (PDF)".
> > 
> > You have to use a Refresh() javascript function after adding the layer.
> > 
> > Hidekazu
> > 
> > --- Jim O'Leary <joleary.public at gmail.com> wrote:
> > 
> >> 
> >> I am saving a new layer and  layer group directly in the XML of the map
> >> definition using SetResource(). This works fine, but the runtime map
> >> doesn't
> >> know about the new layer and group, so gives me an "object not found
> >> error".
> >> Reloading the map frame with JavaScript also causes problems. Is there a
> >> way
> >> to let the runtime map know about the new map definition in the
> >> repository
> >> without a total reload of the frameset? Something like "map::close()"?
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/Reloading-runtime-map-tf3417419s16610.html#a9524481
> >> Sent from the MapGuide Users mailing list archive at Nabble.com.
> >> 
> >> _______________________________________________
> >> mapguide-users mailing list
> >> mapguide-users at lists.osgeo.org
> >> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> >> 
> > 
> > _______________________________________________
> > mapguide-users mailing list
> > mapguide-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapguide-users
> > 
> > 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Reloading-runtime-map-tf3417419s16610.html#a9526840
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 



More information about the mapguide-users mailing list