Programmatically Add Layer

TatukGIS Internet Server Samples


Source code

This TatukGIS Internet Server sample (specifically the sample code) shows how to programmatically create and add a layers.


addLayer.aspx    Top

                        
<%@ Page Language="VB" Debug="True" %>
<%@ Register TagPrefix="ttkGIS" Namespace="TatukGIS.IS" Assembly="TatukGIS.IS" %>
<script runat="server">

    Dim GisUtils As API.XGIS_Utils

    Sub GIS_FullExtent_Click(sender As Object, e As ImageClickEventArgs)
            GIS.FullExtent
    End Sub

    Sub GIS_ZoomIn_Click(sender As Object, e As ImageClickEventArgs)
        GIS.ZoomIn
    End Sub

    Sub GIS_ZoomOut_Click(sender As Object, e As ImageClickEventArgs)
        GIS.ZoomOut
    End Sub

    Sub GIS_Smaller_Click(sender As Object, e As ImageClickEventArgs)
        GIS.Width  = Unit.Pixel( GIS.Width.Value  - 54 )
        GIS.Height = Unit.Pixel( GIS.Height.Value - 40 )
    End Sub

    Sub GIS_Larger_Click(sender As Object, e As ImageClickEventArgs)
        GIS.Width  = Unit.Pixel( GIS.Width.Value  + 54 )
        GIS.Height = Unit.Pixel( GIS.Height.Value + 40 )
    End Sub

    Sub GIS_Load(sender As Object, e As EventArgs)
        GisUtils = New API.XGIS_Utils

        Dim ll As API.XGIS_LayerSHP
        Dim prm as API.IXGIS_ParamsList

        'add new layers
        ll = New API.XGIS_LayerSHP
        ll.Path = (GisUtils.GisSamplesDataDir + "states.shp")
        ll.Name = "states"
        GIS.API.Add(ll)


        'add rivers
        ll = New API.XGIS_LayerSHP
        ll.Path = (GisUtils.GisSamplesDataDir + "rivers.shp")
        ll.Name = "rivers"
        ll.UseConfig = False
        ll.Params.Line.OutlineWidth = 0
        ll.Params.Line.Width = 3
        ll.Params.Line.Color = RGB(0, 0, 255)

        GIS.API.Add(ll)

        'show layers in the viewer
        GIS.FullExtent()
    End Sub

</script>
<html>
<head>
    <title>TatukGIS IS Sample</title>
    <link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <a name="top"></a>
    <h1>Programmatically Add Layer and Render
    </h1>
    <h2 class="comment"><a href="../../samplesAPI.htm">TatukGIS Internet Server Samples</a>
    </h2>
    <form runat="server">
        <p>
            <br />
        </p>
        <table style="WIDTH: 237px; HEIGHT: 204px" cellspacing="0" cellpadding="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <asp:ImageButton id="GIS_FullExtent" onclick="GIS_FullExtent_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/fullextent.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_ZoomIn" onclick="GIS_ZoomIn_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/zoomin.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_ZoomOut" onclick="GIS_ZoomOut_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/zoomout.gif"></asp:ImageButton>
                    </td>
                    <td align="right">
                        <asp:ImageButton id="GIS_Smaller" onclick="GIS_Smaller_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/smaller.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_Larger" onclick="GIS_Larger_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/larger.gif"></asp:ImageButton>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <p>
                            <ttkGIS:XGIS_VIEWERIS id="GIS" runat="server" BorderWidth="1px" BorderColor="CornflowerBlue" OnLoad="GIS_Load" Width="360px" Height="280px"></ttkGIS:XGIS_VIEWERIS>
                        </p>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>