Infrastructure Map Server Developer

Reply
Active Member
anand_ganesh
Posts: 10
Registered: ‎12-03-2009
Message 1 of 5 (772 Views)

Obtain refrence to MgMap Handle

772 Views, 4 Replies
12-03-2009 09:08 AM
Hello All,

I am new to MapGuide Development. I am using MapGuide 2010 and .NET Development.

This is what I am trying to achieve.

The MapGuide GIS Map is already visible in an Internet Explorer Window.

I should be able to obtain the MgMap Handle and remove or add additional GIS Layers and refresh both Map and Legend.

Can you please give me some suggestions on how I can obtain the Map Handle reference from an existing IE Window ?

Thanking you for your time.

With best regards
Anand
Valued Contributor
sakkaku
Posts: 51
Registered: ‎01-03-2007
Message 2 of 5 (772 Views)

Re: Obtain refrence to MgMap Handle

12-14-2009 10:27 AM in reply to: anand_ganesh
When a window is opened via mapguide it will always (as far as I have seen) have session and mapname passed to it.

Example (If your using < .NET 3.5 you will need to specify the types instead of var):

MapGuideApi.MgInitializeWebTier("/path/to/www/webconfig.ini");

var siteconnection = new MgSiteConnection();

var user = new MgUserInformation(session);
siteconnection.Open(user);

var map = new MgMap(siteconnection);
Map.Open(mapname);

I think that should work. I wrote up a class that handles the session, initializing the map, opening maps via layout/definition/etc.
I would recommend doing that rather then copying and pasting the above for every report.
You can stick MapGuideApi.MgInitializeWebTier() in Application_Start() in global.asax to avoid needing to call it every time a report is opened.

Also I would use the viewer API to refresh the map/legend. The server side functions don't work for the ajax viewer from what I have seen.
Active Member
anand_ganesh
Posts: 10
Registered: ‎12-03-2009
Message 3 of 5 (772 Views)

Re: Obtain refrence to MgMap Handle

12-17-2009 03:49 PM in reply to: anand_ganesh
Is it possible to get the Map Handle (MgMap) if I already know the Session String and Map Name from a different page.

For example let us say the GIS Map is already visible (Window1). I know the session string and Map name also.

Now from a different page (Window2) when the user clicks a button I should add/remove layers in this GIS map (Window1).

I tried to create MgMap handle using the Session String and Map Name during the Postback of Window2 and it throws an error saying "Resource Not found".

Any thoughts please ?

Thanks a bunch for spending time and speaking with me.

Regards
Anand
Valued Contributor
sakkaku
Posts: 51
Registered: ‎01-03-2007
Message 4 of 5 (772 Views)

Re: Obtain refrence to MgMap Handle

12-17-2009 03:58 PM in reply to: anand_ganesh
It should work. If you postback to the same page make sure that you store the session and mapname into a hidden field so subsequent requests also have the data. The session and mapname for the most part wont change until the user opens mg again or the session expires.
Active Member
anand_ganesh
Posts: 10
Registered: ‎12-03-2009
Message 5 of 5 (772 Views)

Re: Obtain refrence to MgMap Handle

12-17-2009 04:03 PM in reply to: anand_ganesh
If I post back to the same page yes it will work.

My situation is I have two different pages (Windows).

One window has the GIS Map. This is Window 1.

Another window has just some buttons like "Add Layer" and "Remove Layer" This is Window2. Any click on these buttons causes a postback on Window2.

So my question when Window2 posts back can I still use the Session and MapName and get hold of the MgMap handle in Window 1.

Is this technically possible ?

Thanks
Anand

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community