[mapguide-users] Adding a point to a map... PLZ Help!!! (.NET - C#)
Galois
amihalas at yahoo.gr
Mon Oct 13 09:04:01 EDT 2008
Hello,
I´m trying to add a point to a map but I have no idea how to it.
I have declare the map object, and also I create a point with it's
coordinates.
But I don't know what is the next step that I have to do...
The code follows....
public partial class _Default : System.Web.UI.Page
{
public string sessionId;
public string webLayout;
protected void Page_Load(object sender, EventArgs e)
{
string physicalPath = @"C:\Program
Files\MapGuideOpenSource\WebServerExtensions\www\webconfig.ini";
try
{
MapGuideApi.MgInitializeWebTier(physicalPath);
passAndSession();
//Associate a session ID with the MgSiteConnection Object
MgUserInformation userInfo_new = new
MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo_new);
MgResourceService resourceSrvc =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgMap map = new MgMap(siteConnection);
webLayout =
"Library://GoSpatial/Web+Layouts/Autostrada+Brescia+Padova+Map.WebLayout";
MgResourceIdentifier resId = new
MgResourceIdentifier("Library://GoSpatial/Maps/Italy Map.MapDefinition");
String mapName = resId.GetName();
MgResourceIdentifier mapStateId = new
MgResourceIdentifier("Session:" + sessionId + "//" + mapName + "." +
MgResourceType.Map);
map.Create(resourceSrvc, resId, mapName);
map.Save(resourceSrvc, mapStateId);
map.Open(resourceSrvc, mapName);
createPoint();
}
catch (Exception ex)
{
throw (ex);
}
}
public string passAndSession()
{
MgUserInformation userInfo = new MgUserInformation("Administrator",
"admin");
MgSite site = new MgSite();
site.Open(userInfo);
sessionId = site.CreateSession();
return sessionId;
}
public MgPoint createPoint()
{
MgGeometryFactory geometryFactory = new MgGeometryFactory();
MgCoordinateXY coordinate = (MgCoordinateXY)
geometryFactory.CreateCoordinateXY(10.913161, 45.408046);
MgPoint point = geometryFactory.CreatePoint(coordinate);
return point;
}
}
--
View this message in context: http://www.nabble.com/Adding-a-point-to-a-map...-PLZ-Help%21%21%21-%28.NET---C-%29-tp19954532p19954532.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list