[mapguide-users] Reloading runtime map

Jim O'Leary joleary.public at gmail.com
Sat Mar 17 02:05:58 EDT 2007


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.



More information about the mapguide-users mailing list