[mapguide-users] Reloading runtime map

Hidekazu Shimaji hshimaji at ybb.ne.jp
Wed Mar 21 11:02:12 EDT 2007


Hello Jim,

I'm sorry again I misraed your mail.
Refreshing after adding a layer is the problem, right?
The Refresh function (Viewer API) worked well in my case, 
and I could not understand what the problem was.

I tried 2 viewers, and found that 
if I use the AJAX viewer, the Refersh function works, 
but if I use the DWF viewer, the Referesh function does not work well.
the legend of the new layer appears, 
but objects of the new layer in the map area would not appear.
After I uncheck the legend and check it again, objects will appear finally.

But this case even seems different from your case.
Sorry I cannot help you, and I hope somebody will help us.

Hidekazu

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

> 
> Here is what works:
> 
> 1. Change the XML for the map in the repository.
> 2. Make the new group and/or layer in the runtime map using the Web API.
> 3. Using JavaScript, reload the map frame. From the task pane, this is:
> 
> parent.parent.mapFrame.location.reload(true);
> 
> Now the new group and/or layer shows up in the Layers pane. When you change
> the runtime layer using the Web API, it changes the XML in the repository.
> 
> 
> 
> Hidekazu Shimaji wrote:
> > 
> > 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
> >> 
> > 
> > _______________________________________________
> > 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#a9556893
> 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