[mapguide-users] A simple .Net sample

Andy Morsell amorsell at spatialgis.com
Mon Mar 27 17:27:44 EST 2006


Steve,
If you look at the dwfviewersample.aspx (inserted below) file in the
C:\Program
Files\MapGuideOpenSource\WebServerExtensions\www\dotnetviewersample folder,
you will see that it is the ASP.NET equivalent (or close) to what Bob posted
in PHP.  Not all ASP.NET programmers like to use Visual Studio and create
the overhead of a project when all of the extraneous files are often not
needed.  I prefer to have complete control over what is being written rather
than letting a GUI do it all for me. I know it may be a little unusual and
inefficient, but I do all of my ASP.NET development in Dreamweaver and write
.NET purely in the raw form.  I do everything code-behind, if possible, and
I compile with the command line.  
 
Is this the right way to do things?  Maybe.  Is your way the right way to do
things?  Maybe.  The point is, there is more than one way to achieve the
same goal and different people have different preferences and what is
totally logical to one person, may be illogical to the next.
 
You should be able to take the .NET sample application and modify it for
your own use.  It's very easy to translate it to code-behind.  You can also
create your application in whatever folder you want with no (physical)
dependency on the rest of the MGOS web-tier.  The way the example
application works is that the various functions are called through the
out-of-the-box task pane, maybe that's why it looks like everything is so
disjointed to you? 
 

Andy Morsell, P.E. 
Spatial Integrators, Inc. 
http://www.SpatialGIS.com 

 

<%@ Page language="c#" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<!-- #Include File="utilityfunctions.aspx" -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%
    // Initialize a Aspx session and register a variable to hold the
    // session id, then initialize the Web-Extensions, and connect
    // to the site, and create a session.

    String mapDefinition =
"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition";
    String webLayout =
"Library://Samples/Sheboygan/Layouts/SheboyganAsp.WebLayout";
    String sessionId = "";

    try
    {
        MapGuideApi.InitializeSockets();
        InitializeWebTier();

        MgUserInformation userInfo = new MgUserInformation("Anonymous", "");
        MgSite site = new MgSite();

        site.Open(userInfo);

        sessionId = site.CreateSession();

        MapGuideApi.TerminateSockets();
    }
    catch (MgException mge)
    {
        Response.Write(mge.GetMessage());
        Response.Write(mge.GetDetails());
        MapGuideApi.TerminateSockets();
    }
%>

<html>

<head>
    <title>Viewer Sample Application</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta http-equiv="content-script-type" content="text/javascript" />
    <meta http-equiv="content-style-type" content="text/css" />
    <link href="styles/globalstyles.css" rel="stylesheet" type="text/css">
</head>


<frameset rows="110,*" frameborder="NO" border="0" framespacing="0">
  <frame src="title.aspx?AppName=DWF" name="TitleFrame" scrolling="NO"
noresize>
  <frame src="/mapguide/mapviewernet/dwfviewer.aspx?SESSION=<%= sessionId
%>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame">
</frameset><noframes></noframes>

</html>

  _____  

From: Steven J Reed [mailto:sjreed at edcomputing.com] 
Sent: Monday, March 27, 2006 1:34 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] A simple .Net sample



Bob,

 

I think you are missing something.you gave a PHP example when the thread is
asking for a simple .Net example!  I suppose I can translate the PHP to Java
and go from there, but what I was asking for is a .Net example!

 

Even so, the simple example that you provided is the first simple piece of
code I've seen!

 

Simple .Net applications don't involve hard-coding stuff in HTML.  .Net
programmers are used to dragging an object from the Toolbar onto a page,
setting properties on the Property Pages, maybe writing some code in VB or
C# in the Page_Load method, and having the application work.  Once the app
works in a rudimentary form, they may add server-side event handling
routines to add functionality.  Almost as a last resort and/or to improve
performance, consideration is given to client side code.

 

Examples of .Net applications are typically distributed as .Net solutions or
projects, where the user can unzip a complete application and run it without
having to make significant changes. Really good samples are distributed in
both VB and C#!

 

.Steve

 

  _____  

From: Robert Bray [mailto:robert.bray at autodesk.com] 
Sent: Sunday, March 26, 2006 1:47 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] A simple .Net sample

 

Ok guys, I am a little confused by this thread. Here is the most basic
example (in PHP):

 

<?php

      include '../mapviewerphp/constants.php';

 

      MgInitializeWebTier('C:\Program
Files\MapGuideOpenSource\WebServerExtensions\www\webconfig.ini');

 

      $site = new MgSite();

      $site->Open(new MgUserInformation("Anonymous", ""));

 

      $sessionId = $site->CreateSession();

      $webLayout =
"Library://Samples/Sheboygan/Layouts/SheboyganPhp.WebLayout";

?>

 

<html>

 

<head>

    <title>Simple Sample Application</title>

</head>

 

<body marginheight="0" marginwidth="0">

<iframe id="viewerFrame" width="100%" height="100%" frameborder=0
scrolling="no" src="../mapviewerphp/ajaxviewer.php?SESSION=<?= $sessionId
?>&WEBLAYOUT=<?= $webLayout ?>"></iframe>

</body>

</html>

 

That's it that's all. As long as you define a web layout in MapGuide Studio
you do not need to worry about the content of the mapviewerphp folder. That
is installed as part of the product and is not part of the sample.

 

If you do not like the UI provided by MapGuide, turn off all of the elements
in the web layout and create your own with HTML/JavaScript. I think Alain
also posted an example to this list recently that modified the default
viewer, placing the legend/layer control on the right.

 

Am I missing something wrt your questions?

 

Bob

 

  _____  

From: triplederby100-propos at yahoo.com
[mailto:triplederby100-propos at yahoo.com] 
Sent: Friday, March 24, 2006 6:26 PM
To: users at mapguide.osgeo.org
Subject: Re: [mapguide-users] A simple .Net sample

 

... and not to mention the processing of template files and replacing string
tokens with some real values at runtime :) Very crafty. But it appears
that's what the "viewer" (as designed) is comprising of. 

But there must be a straight-forward way of getting a client up and running,
be it in .NET or whatever, like I am with MapServer. I second what you say.

Kaarigar
====================



----- Original Message ----
From: Steven J Reed <sjreed at edcomputing.com>
To: users at mapguide.osgeo.org
Sent: Friday, March 24, 2006 5:13:19 PM
Subject: [mapguide-users] A simple .Net sample



Would it be too much to ask for a simple .Net sample, say something where
the code was all in one place?  The current ajaxviewersample and
dwfviewersample are really just shells that include code from other
directories, then when you look at them they include still more code.  It is
difficult to determine what is really needed!

 

While I'm asking, why aren't the .Net samples in the form of .Net projects?
If you really want .Net programmers to use this put it in the form they are
used to seeing, which is not something that has to be put in a Program
Files\ MapGuideOpenSource\ WebServerExtensions\ www directory!

 

And of course these samples should have much of the initialization code in
the code-behind module, not embedded in the html code.  

 

Enough bitching, but it really looks like the .Net implementation is an
afterthought!

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide_users/attachments/20060327/058862a5/attachment.html


More information about the Mapguide_users mailing list