/// <summary> /// This method gets the map object out of the mapfactory with given mapalias and /// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client. /// </summary> /// <remarks>None</remarks> public override void Process() { // Extract points from the string System.Drawing.Point [] points = this.ExtractPoints(this.DataString); MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } // There will be only one point, convert it to spatial MapInfo.Geometry.DPoint point; map.DisplayTransform.FromDisplay(points[0], out point); IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias]; if (lyr == null) { TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias); // Make the table mappable ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys())); ti.Columns.Add(ColumnFactory.CreateStyleColumn()); Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti); map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias)); } lyr = map.Layers[SampleConstants.TempLayerAlias]; if (lyr == null) { return; } FeatureLayer fLyr = lyr as FeatureLayer; MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point); // Create a Point style which is a red pin point. SimpleVectorPointStyle vs = new SimpleVectorPointStyle(); vs.Code = 67; vs.Color = Color.Red; vs.PointSize = Convert.ToInt16(24); vs.Attributes = StyleAttributes.PointAttributes.BaseAll; vs.SetApplyAll(); // Create a Feature which contains a Point geometry and insert it into temp table. Feature pntFeature = new Feature(geoPoint, vs); MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature); // Send contents back to client. MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }