[mapguide-users] How to create Layer and Datasource and link it to SQL 2008 Datasource in code

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Thu Feb 5 02:30:56 EST 2009


It's a bit unclear to me what you are asking for.

Do you want to create a FeatureSource by code, a LayerDefiniton, or both?

Both are constructed from xml files, and the xml file definitions can be 
found in the "schemas" subfolder of your MapGuide installation.

The easy way to do this is usually to setup the 
FeatureSource/LayerDefinition in Studio/Maestro
Then save the Xml, and use that as a template for creating new items.
Eg, in the LayerDefinition, change the color, or FeatureSource/Table.

You create a new item by calling the SetResource method on an 
MgResourceService object.

For sample code, feel free to browse the Maestro repository (in C#):
http://trac.osgeo.org/mapguide/wiki/maestro/Sourcecode

For instance, the MSSQL provider editor is here:
http://svn.osgeo.org/mapguide/trunk/Tools/Maestro/Maestro/ResourceEditors/FeatureSourceEditors/MSQLSpatial/FeatureSourceEditorMSSQLSpatial.cs

Regards, Kenneth Skovhede, GEOGRAF A/S



miansi skrev:
> Hello,
>
> I've got my Datasource pointing to the SQL 2008 database. In the database I
> have few views which I would like to expose as layers on the map. I am using
> FDO 3.3.2
>
> http://n2.nabble.com/file/n2267589/image001.jpg 
>
> I saw following examples:
> http://n2.nabble.com/Draw-Line-ASP-.NET...-td1818630.html
> http://svnmirror.osgeo.org/mapguide/tags/MAPGUIDE2.0.1/Web/src/mapviewerjava/measure.jsp
>
> and I read "Another Way To Create Layers" from MGOS 2.0 Developer's Guide.
>
> I think that I understand the core idea, but need help with details as I
> have troubles modifying code from the examples above to fit my requirements.
>
> Can I find somewhere guide as how to programmatically add/remove SQL 2008
> datasource and layer attached to this datasource? Or maybe someone will be
> generous enough to share sample of code?
> I do not care if it would be PHP, Java, VB or C#. Will be able to understand
> C++ too :-)
>
>
> Thank you!
>   


More information about the mapguide-users mailing list