[mapguide-users] Getting started using Visual Studio 2005

Mark Pendergraft markp at Meadgilman.com
Sun Jul 1 19:48:23 EDT 2007


I have created an application in VS 2005.... and it took me a while.

My advice to you is to do the following:

1.) Open IIS create a virtual directory under C:\Program
Files\MapGuideOpenSource\WebServerExtensions\www\
Name it whatever you like (mine is 'MGA Apps')

2.) In IIS make this virtual directory an application by right clicking
it, selecting properties, and then clicking the create button in the
middle of the page (Virtual directory tab)

3.) now copy the bin directory from the dotnetviewersample and the
web.config file into your program directory.  I would also recommend
copying the file 'UtilityFunctions.aspx' as well.
-as a side note:  I originally tried to setup the 1.1 mapguide
server..... don't bother, setup the 1.2 and make sure to get the
dotnetviewersample1.2

4.) Now open visual studio 2005.  Select 'open a website'.  When the
open dialog box appears, select "Local IIS" from the left pane.  Then
browse to the directory you created.

5.) Once the app is open, add a reference to the dotnetmanagedapi.dll

6.) You can now add a page.  Set your page up like so:  (I'm writing in
VB, you can find translators on the internet)

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="OSGeo.MapGuide" %>

<!-- #Include File="UtilityFunctions.aspx" -->

<script runat="server">
    Private webLayout As String =
"Library://Kroll/Layout/MGAJobMapLayout.WebLayout"
    Private defaultUser As String = "Anonymous"
    Private defaultPassword As String = ""
    Private SessionId As String = ""
</script>
    
<%
    Try
        ' Initialize a session and register a variable to hold the
        ' session id, then initialize the Web Extensions, connect
        ' to the site, and create a session.

        InitializeWebTier()

        Dim userInfo As New MgUserInformation(defaultUser,
defaultPassword)
        Dim site As New MgSite()
        site.Open(userInfo)
        sessionId = site.CreateSession()
        
    Catch e As Exception
        Response.Write(e.Message)
    End Try
    
%>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test Map</title>
</head>
<frameset rows="30,*">
	<frame id="titleFrame" frameborder="0" marginwidth="0"
marginheight="0" scrolling="no" src="title.html">
	<frame id="viewerFrame" frameborder=0 marginwidth="0"
marginheight="0" scrolling="no"
src="../mapviewernet/ajaxviewer.aspx?SESSION=<%=sessionId%>&WEBLAYOUT=<%
=webLayout%>">
</frameset>
</html>

-So in this page, you will need to set a layout to open.  If you haven't
created one, download the AutoDesk Map Studio 2007 trial from
www.autodesk.com and follow the steps to create a layout.

So basically all this page does is setup your map....
Now you are ready to write an application that actually does something.

Create a new page, in the page, you will need to call the
InitializeWebTier function (located in the UtilityFunctions.aspx) and
open a map to do pretty much anything.

Use AutoDesk Map Studio to set the default task pane page (my main
testing page as of right now) and then you can add commands which will
reference other URL's.

Now you are ready to read the developer's guide and try to translate the
PHP code into .NET.  when you figure out how to select features, and
make it show up on the map...feel free to tell me how you did it.

Well, there you go.  I hope that helps, I tried several times to get an
app up and this is how it finally happened.


More information about the mapguide-users mailing list