Hey guys,
I am totally frustrated now. After reconstructing and trying lots of examples
to show a damn point in the map I did not get it to work.
The most example codes are offline and the demo project for the "markup
feature" does also not work.
Now in the last step I tried to avoid to create the layer programmatically and
created it in the Maestro.
But now the code
featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection,
false);
does not throw an exception and does also not work.
Has someone a solution for me - preferred in c# .Net for the Ajax viewer which
knowly works?
I can´t believe that it is so hard to show a damn point in the map.
Here is the last way I have tried - (last one of lots before):
void ShowPoint()
{
//---------------------------------------------------//
// Initialize
InitializeWebTier();
sessionId = Request.Params["SESSION"];
mapName = Request.Params["MAPNAME"];
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resourceService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgFeatureService featureService =
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
//---------------------------------------------------//
// Open the map
MgMap map = new MgMap(siteConnection);
map.Open(mapName);
MgBatchPropertyCollection batchPropertyCollection = new
MgBatchPropertyCollection();
String featureSourceName = "Library://test/shapes/POIs.FeatureSource";
//String featureSourceName =
"Library://test/layer/POIs.LayerDefinition";
MgResourceIdentifier resourceIdentifier = new
MgResourceIdentifier(featureSourceName);
// Make the point
batchPropertyCollection.Add(MakePoint("Point A", x, y));
// Add the batch property collection to the feature source
MgInsertFeatures cmd = new MgInsertFeatures("POIs",
batchPropertyCollection);
MgFeatureCommandCollection featureCommandCollection = new
MgFeatureCommandCollection();
featureCommandCollection.Add(cmd);
// Execute the "add" commands
featureService.UpdateFeatures(resourceIdentifier,
featureCommandCollection, false);
// Saving the map
map.Save(resourceService);
//map.save
string script = "parent.Refresh();";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Refresh",
script, true);
ClientScript.RegisterStartupScript(this.GetType(), "Refresh",
"Refresh();");
}
///////////////////////////////////////////////////////////////////////////////////
MgPropertyCollection MakePoint(String name, double x, double y)
{
MgPropertyCollection propertyCollection = new MgPropertyCollection();
MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
MgGeometry geometry = (MgPoint)wktReaderWriter.Read("POINT XY (" +
x.ToString().Replace(',', '.') + " " + y.ToString().Replace(',', '.') + ")");
MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
MgGeometryProperty geometryProperty = new
MgGeometryProperty("Geometry", geometryByteReader);
//propertyCollection.Add(new MgInt32Property("FeatId", 6));
propertyCollection.Add(new MgStringProperty("Name", "Name"));
propertyCollection.Add(new MgGeometryProperty("Geometry",
geometryByteReader));
wktReaderWriter.Dispose();
agfReaderWriter.Dispose();
return propertyCollection;
}
Best Regards
David
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users