[mapguide-users] Reloading runtime map

Hidekazu Shimaji hshimaji at ybb.ne.jp
Fri Mar 16 20:51:05 EDT 2007


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
> 



More information about the mapguide-users mailing list