[mapguide-internals] Intergrating DWF Viewer of MapGuide Enterprise 2009 into Windows Forms

Walt Welton-Lair walt.welton-lair at autodesk.com
Thu Aug 28 10:38:53 EDT 2008


Carl,

With DWF Viewer you have an outer control - the ExpressViewer - and different inner controls (document handlers) - EPlotViewer, EMapViewer, etc.

You need to create an instance of the ExpressViewer, and then call its DocumentHandler property to get the inner EMapViewer control.  You'll also need to set the SourcePath before you can get the inner control.  That's because the ExpressViewer doesn't know what kind of DWF you are viewing until you set the SourcePath.  Once set it can read the first few bytes, determine the type of DWF, and instantiate the correct type of inner control.

The SourcePath in your case is a GETMAP HTTP request to the MapGuide server.  Use an HTTP sniffer to see examples of this request.  It will be something like:

<mapAgentLocation>?OPERATION=GETMAP
        &VERSION=1.0.0
        &DWFVERSION=6.01
        &EMAPVERSION=1.0
        &MAPDEFINITION=<mapDefinitionResource>
        &LOCALE=<2-letter-locale>

You can optionally include
        &SETVIEWCENTERX=<viewCenterX>
        &SETVIEWCENTERY=<viewCenterY>
        &SETVIEWSCALE=<viewScale>


Hopefully this is enough to point you in the right direction.

Walt

-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Kenneth Skovhede, GEOGRAF A/S
Sent: Thursday, August 28, 2008 5:52 AM
To: MapGuide Internals Mail List
Subject: Re: [mapguide-internals] Intergrating DWF Viewer of MapGuide Enterprise 2009 into Windows Forms

I have not tried to do this with the DWF viewer, but have done it with
the MapGuide 6.5 viewer.

If you look at the DWFViewer html files for MapGuide, you should be able
to find the GUID of the desired class (the map viewer).
With this GUID, you can search the registry to find the name of the
component.

In Visual Studio, you can pick the component, by adding a reference, and
selecting it on the "COM" tab.
If you found the right class, it will generate a wrapper assembly that
is also a .Net control.
You can then add the control as a normal control.
You should also be able to see the properties for the control.

There is also a tool to generate the assembly outside of Visual Studio,
but I can't remember its name.

Regards, Kenneth Skovhede, GEOGRAF A/S



Carl Jokl skrev:
> I have a task in migration of a Windows Forms based Application which embeds
> the DWF Viewer of MapGuide 6. The Migration is basically just to swap out
> the MapGuide 6 DWF Viewer ActiveX Control and instead replace it with the
> MapGuide Enterprise 2009 DWF Viewer ActiveX control. I am having some
> difficulty in this due to working slightly blind on this without complete
> documentation on how to do something like this. I am using the
> EMapViewer.dll library and examining the classes within it but am not
> certain that this is the correct library or whether this library has other
> dependencies (though that I may be able to check with a dependency walker
> utility). I manage to create an instance of the CEmapViewerClass which I am
> guessing is what should be instantiated. I need to point this to a map
> though and tried using the NavigateTo method to supply the URL to be used.
> This action threw a COM Exception which I think may be due to no map being
> loaded (though this is what I am trying to do anyway). I am able to see some
> of the internal state of the viewer as I have turned on native debugging.
>
> Item 1 which I need to get working is getting the Map Viewer to load a map
> at a given URL.
>
> My second problem is that as this application is Windows Forms based (ableit
> written in C# .Net) I need to be able to cast the ActiveX control to be some
> kind of component which can be added to a form as well as do things like set
> the position and size and docking etc.
>
> Item 2 be able to use DWF ActiveX control as Windows Forms Component.
>
> I could be going about this whole process wrongly but I am somewhat working
> blind at the moment without guidence. I have a document about the DWF Viewer
> API which shows me the methods available and events and some coverage of
> what the classes are. The guide I have is not detailed enough to cover items
> 1 and 2 which I am trying to figure out. I am aware that the DWF Viewer has
> wider scope usage than MapGuide alone and can be intergrated in many types
> of applications. I have looked a bit on Autodesks site for documentation.
> There is some but it can be patchy. For example when I try and download code
> examples some deny access another one was a zip download file 0 bytes in
> size. I would appreciate any help anyone may be able to provide.
>
_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals


More information about the mapguide-internals mailing list