Reading or constructing shap layers from ms sql server, is it possible even, through indirect method?

Hello

I am not talking about bubbles setting. I am talking about the vector layers.

I am asking because one of the shape files is for roads, and it contains about 16 million row, loading it is a disasters. But using a simple sql statement like "SELECT GEOM_COL FROM ROADS,PERCINCTS WHERE GEOM_COL.STINTERSECT(PERCINCTS.GEOM_COL);" will reduce the result set to couple of thousands if not couple of hundreds rows.

My second question is there a way to put custom markers like ".ico",".bmp",".jpg" ....etc in place of bubbles usual appearance?



1 Reply

SS Sridevi Sivakumar Syncfusion Team July 26, 2021 01:22 PM UTC

Hi Mohammed AbdelAl,

Query 1: How to load the shapefile from SQL server?


We have .Json file support in WinForms Maps. Can you please convert SQL data to json file and load to Maps control to render shape. Please refer below code snippet to load the .json file in Maps.

[Form1.cs]:

            this.mapsControl1.Margin = new Padding(0, 0, 4, 0);

            this.mapsControl1.MapBackgroundBrush = new SolidBrush(Color.White);

            this.mapsControl1.MapItemsShape = Syncfusion.Windows.Forms.Maps.MapItemShapes.None;

            this.mapsControl1.MapItemStroke = new SolidBrush(Color.Black);

            ShapeFileLayer shapeLayer = new ShapeFileLayer();

            shapeLayer.ShapeSetting.FillSetting.AutoFillColors = false;

            shapeLayer.ShowMapItem = true;

            shapeLayer.Uri = "world1.json";

            shapeLayer.ShapeIDPath = "NAME";

            shapeLayer.ShapeIDTableField = "NAME";

            shapeLayer.ShowMapItem = true;           

            shapeLayer.ShapeSetting.ShapeFill = "#626171";

            shapeLayer.ShapeSetting.ShapeStrokeThickness = 0.5;

            shapeLayer.ShapeSetting.ShapeStroke = "#C1C1C1";

            shapeLayer.ShapeSetting.FillSetting.AutoFillColors = false;

….



Query 2My second question is there a way to put custom markers like ".ico",".bmp",".jpg" ....etc in place of bubbles usual appearance?

We can place the ".ico",".bmp",".jpg"  type images as annotation items of SfMaps, but we can't set the image to the bubbles.

this.mapsControl1.Margin = new Padding(0, 0, 4, 0);

            this.mapsControl1.MapBackgroundBrush = new SolidBrush(Color.White);

            this.mapsControl1.MapItemsShape = Syncfusion.Windows.Forms.Maps.MapItemShapes.None;

            this.mapsControl1.MapItemStroke = new SolidBrush(Color.Black);

            ShapeFileLayer shapeLayer = new ShapeFileLayer();

          ….

 

       

        shapeLayer.Annotations = new ObservableCollection<Annotation>(){

            new SyncfusionLocations() { Name = "USA", Latitude = 38.8833, Longitude = -77.0167},

            new SyncfusionLocations() { Name = "Brazil", Latitude = -15.7833, Longitude = -47.8667},

            new SyncfusionLocations() { Name = "India", Latitude = 21.0000, Longitude = 78.0000},

            new SyncfusionLocations() { Name = "China", Latitude = 35.0000, Longitude = 103.0000},

            new SyncfusionLocations() { Name = "Indonesia", Latitude = -6.1750, Longitude = 106.8283},

 

        };

 

       

            this.mapsControl1.AnnotationDrawing += mapsControl1_AnnotationDrawing;

            this.mapsControl1.Layers.Add(shapeLayer);

          

        }

         void mapsControl1_AnnotationDrawing(object sender, AnnotationDrawingEventArgs e)

        {

            var font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Pixel, ((byte)(0)));

            var font1 = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Pixel, ((byte)(0)));

            StringFormat format = new StringFormat();

            format.FormatFlags = StringFormatFlags.FitBlackBox;

            var location = (e.Annotation as SyncfusionLocations);

            e.Handled = true;

            PointF point = new PointF((float)e.X, (float)e.Y);

              Image img = Image.FromFile("..//..//pin.ico");

            e.Graphics.DrawImage(img, point.X - 10, point.Y - 25, 20, 30);

            e.Graphics.FillRectangle(new SolidBrush(Color.DarkCyan), new RectangleF(point.X + 5, point.Y + 2, 100, 30));

            e.Graphics.DrawString(location.Name, font, new SolidBrush(Color.White), new PointF(point.X + 10, point.Y + 3));

         }



Please have a sample from the below link
https://www.syncfusion.com/downloads/support/directtrac/general/ze/WinfromsMap-150013403




For more information about maps annotation
https://help.syncfusion.com/windowsforms/map/annotations

Let us know if you need any further assistance.

Regards,
Sridevi S.



Loader.
Up arrow icon