Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Obtain refrence to MgMap Handle

4 REPLIES 4
Reply
Message 1 of 5
anand_ganesh
1015 Views, 4 Replies

Obtain refrence to MgMap Handle

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
4 REPLIES 4
Message 2 of 5
sakkaku
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.
Message 3 of 5
anand_ganesh
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
Message 4 of 5
sakkaku
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.
Message 5 of 5
anand_ganesh
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report