[mapguide-users] RE: MAPNAME & Map.Open

Jackie Ng jackie.ng at aecsystems.com.au
Thu Jun 28 02:26:00 EDT 2007


Assume our page is called "Foobar.aspx"

You can invoke this page from your html page in two main ways.

1) A GET request. eg. 

http://..../Foobar.aspx?MAPNAME=TheMap&SESSION=fe2cdb24-ffff-ffff-8000-000c29b536f6_en&...
Invoke Foobar.aspx 

2) A POST request. eg.

<form name="frm" action="Foobar.aspx" method="post">
       <input type="hidden" id="SESSION" name="SESSION"
value="fe2cdb24-ffff-ffff-8000-000c29b536f6_en" />
       <input type="hidden" id="SESSION" name="MAPNAME" value="TheMap" />
       <input type="submit" id="btnsubmit" name="btnsubmit" value="Invoke
Foobar.aspx" />
</form>

Then in the Page_Load method of your Foobar.aspx page:

1) If you used a GET request, you can access your parameters in a
Request.QueryString collection

eg. Dim mapname As String = Request.QueryString("MAPNAME")
     Dim sessionId As String = Request.QueryString("SESSION")

2) If you used a POST request, you can access your parameters in a
Request.Form collection

eg. Dim mapname As String = Request.Form("MAPNAME")
     Dim sessionId As String = Request.Form("SESSION")

And assuming you're using the UtilityFunctions.aspx from the mapviewernet
folder. Then that GetRequestParameters() method conveniently wrappers 1) and
2) so you don't have to know the request type.

eg. Dim mapname As String = GetRequestParameters("MAPNAME")
     Dim sessionId as String = GetRequestParameters("SESSION")

Hope that helps.

- Jackie


Mark Pendergraft wrote:
> 
> Okay regarding number 1, I was hoping you would provide a code snippet
> or a little more info.  I'm pretty new to ASP and I'm having a really
> hard time making javascript and vb.net in ASP jive, as well as just
> having a hard time with javascript in general.
> 
> Regarding number 2....Thank you so much!  I knew it was something
> stupid, it never occurred to me that the username/password would crash
> the map.open procedure.
> 
> Thanks again for the help thus far.
> 
> -Mark P.
> 
> 
> -----Original Message-----
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jackie Ng
> Sent: Wednesday, June 27, 2007 8:55 PM
> To: mapguide-users at lists.osgeo.org
> Subject: Re: [mapguide-users] MAPNAME & Map.Open
> 
> 
> Hi Mark,
> 
> 1) I use the javascript method and store the map name in a hidden form
> field
> so it can be picked up in the Page's Request.Form collection
> 
> 2) I see a few problems with this code,
> 
> - You have two sessionid variables with lower and upper "s" casings.
> - You are new'ing a MgUserInformation object with username/login instead
> of
> the sessionid. This is probably the cause of the failure, becuase
> MAPNAME is
> tied to your session id. If you want to use Map.Open with MAPNAME you
> have
> to open the MgSiteConnection with a MgUserInformation object that has a
> session id, not user/pass.
> 
> Hope that helps.
> 
> - Jackie
> 
> 
> Mark Pendergraft wrote:
>> 
>> I'm hoping that someone can help me with a few questions:
>> 
>>  
>> 
>> 1)  How are people passing the MAPNAME variable to their application
>> pages?   I understand that you can use the javascript function
>> parent.parent.mapframe.getmapname, however, I am unsure how to retain
>> the value from this.  How do I transfer this variable to my asp.net
>> page.
>> 
>>  
>> 
>> 2)  I am unable to open a Map at all.  Every app I have made so far
>> creates a map.  My code thus far:
>> 
>>  
>> 
>> <!-- #Include File="../UtilityFunctions.aspx" -->
>> 
>>  
>> 
>> <script runat="server">
>> 
>>     Private webLayout As String =
>> "Library://Kroll/Layout/MGAJobMapLayout.WebLayout"
>> 
>>     Private MapDef As String = "Library://Kroll/Map/MGA.MapDefinition"
>> 
>>     Private defaultUser As String = "Anonymous"
>> 
>>     Private defaultPassword As String = ""
>> 
>>     Private sessionId As String = ""   
>> 
>> </script>
>> 
>>  
>> 
>> <%
>> 
>>     Try
>> 
>>            
>> 
>>         InitializeWebTier()
>> 
>>  
>> 
>>         Dim SessionId As String = GetRequestParameters("SESSION")
>> 
>>         
>> 
>>         Dim UserInfo As New MgUserInformation(defaultUser,
>> defaultPassword)
>> 
>>         Dim site As New MgSite()
>> 
>>         site.Open(UserInfo)
>> 
>>        
>> 
>>         'for testing purposes only
>> 
>>         If SessionId = "" Then site.CreateSession()
>> 
>>         'for testing purposes only
>> 
>>         
>> 
>>         Dim ResourceService As OSGeo.MapGuide.MgResourceService
>> 
>>         Dim siteconnection As New MgSiteConnection
>> 
>>         siteconnection.Open(UserInfo)
>> 
>>         ResourceService =
>> siteconnection.CreateService(MgServiceType.ResourceService)
>> 
>>        
>> 
>>         Dim MapDefId As New MgResourceIdentifier(MapDef)
>> 
>>         Dim MapName As String = MapDefId.Name
>> 
>>         Dim Map As New MgMap(siteconnection)
>> 
>>         Map.Open(ResourceService, MapName)
>> 
>>                 
>> 
>>         Dim srs As String = Map.GetMapSRS
>> 
>>         
>> 
>>         Response.Write("Map <strong>" + Map.GetName + "</strong> uses
>> this reference system: </br>" + srs + "</br></br></br>")
>> 
>>                 
>> 
>>         Dim MapLayers As MgLayerCollection
>> 
>>         MapLayers = Map.GetLayers
>> 
>>         Dim Layer As MgLayer
>> 
>>         Response.Write("<strong>Map Layers</strong></br>")
>> 
>>         For Each Layer In MapLayers
>> 
>>             Response.Write(Layer.Name + "</br>")
>> 
>>         Next
>> 
>>                                       
>> 
>>     Catch ex As Exception
>> 
>>         Response.Write(ex.Message)
>> 
>>         Response.Write(ex.StackTrace)
>> 
>>     End Try
>> 
>>     
>> 
>> %>
>> 
>>  
>> 
>>  
>> 
>> This code errors out at Map.Open everytime
>> 
>> 
>> _______________________________________________
>> 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/MAPNAME---Map.Open-tf3992128s16610.html#a11336576
> 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/MAPNAME---Map.Open-tf3992128s16610.html#a11337713
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list