This project is read-only.

Connection Legend with Map

Feb 17, 2013 at 11:01 PM
Hello

I'm beginner in using MapWinGis. I use SharpDevelop and my program is in C#.

how to connect legend with map that means if I uncheck layer in legend this layer disappear in map and if I check, layer appear. And if I move up layer in legend, layer in map go up.

Kuba
Feb 18, 2013 at 1:22 PM
You should have a look at the source code of MapWindow: http://svn.mapwindow.org/svnroot/MapWindow4Dev/MapWindow/

From memory I think the legend control has a property you can use to put the axmap object name is.

Paul
Feb 19, 2013 at 8:26 PM
Hello
Thank for your response.
I tried this but it doesn't work. If I set property map I have error:

"Cannot implicitly convert type 'AxMapWinGIS.AxMap' to 'MapWinGIS.Map' (CS0029) - C:\C#\testSHP\testSHP\MainForm.Designer.cs:60,23"
The type 'MapWinGIS.Map' is defined in an assembly that is not referenced. You must add a reference to assembly 'Interop.MapWinGIS"

If I set property:

this.legend1.Map = (MapWinGIS.Map)axMap1;

I have error : Unable to cast object of type 'AxMapWinGIS.AxMap' to type 'MapWinGIS.Map'.

I have referrence :
AxInterop.MapWinGIS
Interop.MapWinGIS
MapWinInterfaces

Below is source code:
private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
        this.axMap1 = new AxMapWinGIS.AxMap();
        this.legend1 = new LegendControl.Legend();
        ((System.ComponentModel.ISupportInitialize)(this.axMap1)).BeginInit();
        this.SuspendLayout();
        // 
        // axMap1
        // 
        this.axMap1.Enabled = true;
        this.axMap1.Location = new System.Drawing.Point(240, 29);
        this.axMap1.Name = "axMap1";
        this.axMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap1.OcxState")));
        this.axMap1.Size = new System.Drawing.Size(502, 297);
        this.axMap1.TabIndex = 0;
        // 
        // legend1
        // 
        this.legend1.BackColor = System.Drawing.Color.White;
        this.legend1.Location = new System.Drawing.Point(12, 29);
        this.legend1.Map = (MapWinGIS.Map)axMap1;
        this.legend1.Name = "legend1";
        this.legend1.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
        this.legend1.SelectedLayer = -1;
        this.legend1.Size = new System.Drawing.Size(222, 297);
        this.legend1.TabIndex = 1;
It is strange, and what is difference AxMapWinGIS.AxMap and MapWinGIS.Map?

Kuba
Feb 21, 2013 at 9:49 AM
You are using the interop dlls that belong to the ocx?
It is best to download all 3 from http://svn.mapwindow.org/svnroot/MapWindow4Dev/Bin/
Those interop dlls are generated by Visual Studio when you add the ocx to your form. I don't know the difference.

Paul