How to add background map (image) to Diagram area?

Is it possible to add a background map (image) to the Diagram area?
If yes, what is the vb.net code (.Net 3.5) to add a background image (map)?
Would that be saved and opened with the diagram file?
Thanks for any help

5 Replies

AL Allen December 26, 2017 03:07 PM UTC

My follow up question is how to make :
1) Is it possible to add Maps (shp file) as background to diagram area? 
2) If #1 is not possible, is it possible to make the diagram control completely transparent so that I can show a map control from below?
3) In general, how can I add a background image (any image format) to the diagram area 

This is a Winforms diagram and am using VB.NET 3.5

I would highly appreciate for any of your assistance 



AL Allen December 26, 2017 09:53 PM UTC

I found the answer for adding a background image to the diagram Me.diagram1.BackgroundImage = New Bitmap("myImage")

Is there a similar approach to add shape file as background to the diagram?  Otherwise, as said below, any possibility to make the diagram control completely transparent to see the Maps control, which will be below the diagram control; or any other approach 



NG Naganathan Ganesh Babu Syncfusion Team December 27, 2017 08:50 AM UTC

Hi Allen, 
 
In order to achieve your requirement, we suggest you to use diagram’s ControlNode and host the Maps control into the controlnode with setting the size of the model. Also, disable the below mentioned Node’s properties to preventing the interaction of that diagram’s node while setting it as a background. 
 
1.      Node.EditStyle’s AllowSelect 
2.      Node.EditStyle’s AllowMove 
 
Please refer to the below code example and sample 
 
Code example: 
 
[C#] 
 
Private Sub AddMapControl() 
            Dim mapsControl1 As New Maps() 
            mapsControl1.Dock = System.Windows.Forms.DockStyle.None 
            mapsControl1.Margin = New System.Windows.Forms.Padding(0, 0, 4, 0) 
            mapsControl1.MapItemFont = Nothing 
            mapsControl1.MapItemsShape = Syncfusion.Windows.Forms.Maps.MapItemShapes.Ellipse 
            mapsControl1.MapItemStroke = Nothing 
            mapsControl1.Name = "mapsControl1" 
            mapsControl1.Size = New System.Drawing.Size(880, 585) 
            mapsControl1.TabIndex = 0 
            mapsControl1.Text = "mapsControl1" 
 
            mapsControl1.Dock = DockStyle.Fill 
            mapsControl1.Margin = New Padding(0, 0, 4, 0) 
            mapsControl1.MapBackgroundBrush = New SolidBrush(Color.White) 
            mapsControl1.MapItemsShape = Syncfusion.Windows.Forms.Maps.MapItemShapes.None 
            mapsControl1.MapItemStroke = New SolidBrush(Color.Black) 
            Dim shapeLayer As New ShapeFileLayer() 
            shapeLayer.ShapeSetting.FillSetting.AutoFillColors = False 
            shapeLayer.Uri = "..//..//world1.shp" 
            shapeLayer.ShapeIDPath = "Country" 
            shapeLayer.EnableSelection = True 
            shapeLayer.SelectionMode = SelectionModes.Multiple 
            shapeLayer.ShapeIDTableField = "NAME" 
            shapeLayer.ShowMapItem = False 
            shapeLayer.ShapeSetting.ShapeValuePath = "Country" 
            shapeLayer.ShapeSetting.ShapeFill = "#E5E5E5" 
            shapeLayer.ShapeSetting.ShapeStrokeThickness = 0.5 
            shapeLayer.ShapeSetting.ShapeStroke = "#C1C1C1" 
            shapeLayer.ShapeSetting.SelectedShapeColor = "#34CBF4" 
            mapsControl1.Layers.Add(shapeLayer) 
 
 
            Dim ctrlNode As New ControlNode(mapsControl1, New RectangleF(New PointF(0, 0), diagram1.Model.LogicalSize)) 
            ctrlNode.EditStyle.AllowSelect = False 
            ctrlNode.EditStyle.AllowMove = False 
            diagram1.Model.AppendChild(ctrlNode) 
End Sub 
 
Sample: 
 
 
Regards, 
 
Naganathan K G  



AL Allen December 27, 2017 11:01 AM UTC

Excellent, thank you so much, Naganathan!

Just one last question related to that (please bear with me):
1) for both image and map cases: how can I auto-fit the diagram areas to the image or map? I loaded GIF image as background and gets distorted. I thought the best way could be to stretch or shrink the diagram area based on the background image size. Obviously, this should apply to the shp file too, right?

2) since most of the background maps that I use are with real-world coordinats  (latitude and altitude), I would like to use custom coordinates on the diagram, i.e, x and y are latitude and longitude instead of the screen coordinates  

I would appreciate if you give me a hand on this very last question, like code adjustments or instructions. 

Once again thank you!



NG Naganathan Ganesh Babu Syncfusion Team January 2, 2018 02:02 PM UTC

Hi Allen, 
 
1) for both image and map cases: how can I auto-fit the diagram areas to the image or map? I loaded GIF image as background and gets distorted. I thought the best way could be to stretch or shrink the diagram area based on the background image size. Obviously, this should apply to the shp file too, right? 
Please confirm us whether your requirement is to set the diagram size as per size of the maps control? if so, we suggest you to use diagram.Model’s LogicalSize property and set the value of map control’s size. please refer to the below code example. 
 
Code example: 
 
[VB] 
 
'setting the diagram's model size as MapsControl size to fit the diagram... 
Dim ctrlNode As New ControlNode(mapsControl1, New RectangleF(New PointF(0, 0), mapsControl1.Size)) 
Me.diagram1.Model.LogicalSize = mapsControl1.Size 
 
If we misunderstood your requirement, please share us more information about your requirement to set the size of the diagram which will help us to analyze further and provide you a better solution. 
 
2) since most of the background maps that I use are with real-world coordinats  (latitude and altitude), I would like to use custom coordinates on the diagram, i.e, x and y are latitude and longitude instead of the screen coordinates  
Based on our internal analyze, we found that we cannot set the diagram coordinates from the map control’s real-world coordinates (i.e. latitude and altitude) values.  
 
Regards, 
 
Naganathan K G 


Loader.
Up arrow icon