[mapguide-users] asp.net example of loading a webmapservice layer
miansi
AndreiSinelnikov at SierraSystems.com
Thu Feb 19 15:21:37 EST 2009
1. Follow this link
http://www.webrade.com/blogs/darrin/2008/05/16/CreatingNETObjectsForMapguideXMLSchemaDefinitionsXSDUsingLINQ.aspx
this will give you intellisence support for all MGOS schemas.
2. I am adding layer to the map this way:
/// <summary>
/// Add new layer to MG repository and to the map
/// </summary>
/// Layer name
/// Layer legend label
/// Layer group name
/// Layer group legend label
/// Layer (of type point) attributes to populate with
/// SQL table (or View) column list
public void AddPointLayerDef2Map(
String layerName
, String layerLegendLabel
, String groupName
, String groupLegendLabel
, LayerPointAttributes attributes
, DataTable dbColumns)
{
// Get or set the resourceid of the map to load
MgResourceIdentifier resourceMap = new
MgResourceIdentifier(this.Attributes.MgMapName);
// Define a new resourseLayer
MgResourceIdentifier resourseLayer = new
MgResourceIdentifier(this.Attributes.MgLayerName(layerName, groupName));
// Create our connection to the resource service
MgResourceService resourceService =
(MgResourceService)this.MgConn.CreateService(MgServiceType.ResourceService);
// Get new Layer XML
String xmlLayer = Spatial.Helper.GetLayerXml(attributes,
dbColumns);
// Save it
// TODO: AS: I think we have to use UpdateResource in case layer
already exists on the map.
// Confirm and update logic
resourceService.SetResource(resourseLayer, new
MgByteReader(xmlLayer, MgMimeType.Xml), null);
// TODO: Check if there is map available and if not:
// 1. Create map
// 2. Create layer
// Get updated map XML
String xmlMap = Spatial.Helper.GetMapXml(
resourceService
, resourceMap
, resourseLayer
, layerName
, layerLegendLabel
, groupName
, groupLegendLabel);
// Save it
resourceService.SetResource(resourceMap, new
MgByteReader(xmlMap, MgMimeType.Xml), null);
}
Two classes participating in:
http://n2.nabble.com/file/n2355204/Helper.cs Helper.cs
http://n2.nabble.com/file/n2355204/MgController.cs MgController.cs
Let me know if that is what you looking for.
Regards
stoff wrote:
>
> Hi,
>
> the devGuide gives an example of adding layers to a map in php.
> Has anybody an comparable example in asp.net?
> I want to load an ogc-wms into the map by loading an existing
> layer.definition.xml to a resource and add the resource to the
> map. The xml-file can by generated for example by the mapguide
> studio ...
>
> Thanks a lot,
>
> stoff
>
>
>
--
View this message in context: http://n2.nabble.com/asp.net-example-of-loading-a-webmapservice-layer-tp2328300p2355204.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list