<font color="#3366ff">Dear All,</font><div><font color="#3366ff">  </font></div><div><font color="#3366ff"><br></font></div><div><font color="#3366ff">   I want to draw line object on map (imagebutton).I do not know how to capture and fist click(xy) and where to store again i need to get second click( second point xy)..and finally i need to draw line on the map in server side(C# or whatever) .I can able to draw point.But i am not able to draw line object and below is my code... Please anyone can help me.</font></div>
<div><font color="#3366ff"><br></font></div><div><font color="#3366ff"><br></font></div><div><font color="#3366ff"><div>       public static void AddFeature(Double x, Double y, String activeLayer, mapObj mainMapObject)</div>
<div>        {</div><div>            try</div><div>            {</div><div>                //check if the active layer is a point layer and if the point layer is from PostGIS</div><div>                LayerObject.Layer  = mainMapObject.getLayerByName(activeLayer);</div>
<div><br></div><div>                if (LayerObject.Layer.type != MS_LAYER_TYPE.MS_LAYER_LINE)</div><div>                {</div><div>                    return;</div><div><br></div><div>                }</div><div><font class="Apple-style-span" color="#FF0000">                //convert the image point in map point Here I am getting issue</font></div>
<div><br></div><div><font class="Apple-style-span" color="#CC0000">                pointObj mapPointObj = Pixel2Geo(new pointObj(x, y, 0, 0), mainMapObject);</font></div><div><font class="Apple-style-span" color="#CC0000"><br>
</font></div><div><font class="Apple-style-span" color="#CC0000">                pointObj secondPoint = Pixel2Geo(new pointObj(0,0,0,0),mainMapObject);</font></div><div><br></div><div><br></div><div>                //add the point to a PostGIS table</div>
<div>                if (LayerObject.Layer.connectiontype == MS_CONNECTION_TYPE.MS_POSTGIS)</div><div>                {</div><div><br></div><div>                    //set CurrentCulture according to PostgreSQL server</div>
<div>                    CultureInfo newCultureInfo = new CultureInfo(&quot;en-US&quot;);</div><div><br></div><div>                    newCultureInfo.NumberFormat.NaNSymbol = &quot;&quot;;</div><div><br></div><div>                    Thread.CurrentThread.CurrentCulture = newCultureInfo;</div>
<div><br></div><div><br></div><div><br></div><div>                    //connect with PostgreSQL</div><div>                    String sqlInsert = &quot;INSERT INTO &quot; + activeLayer + &quot;(name,the_geom) VALUES(&#39;ven&#39;,GeomFromText(&#39;LINESTRING(&quot; + mapPointObj.x.ToString() + &quot; &quot; + mapPointObj.y.ToString() + &quot;,&quot; + secondPoint.x.ToString()+ &quot;&quot; + secondPoint.y.ToString()  + &quot;)&#39;,24047))&quot;;</div>
<div><br></div><div>                    //reads connection string for PostgreSQL</div><div><br></div><div>                    Npgsql.NpgsqlConnection npgSqlConnection = new Npgsql.NpgsqlConnection(ConfigurationSettings.AppSettings[&quot;ConnectionString&quot;].ToString());</div>
<div><br></div><div>                    npgSqlConnection.Open();</div><div><br></div><div>                    Npgsql.NpgsqlCommand cmdCreator = npgSqlConnection.CreateCommand();</div><div><br></div><div>                    cmdCreator.CommandText = sqlInsert;</div>
<div><br></div><div>                    cmdCreator.ExecuteNonQuery();</div><div><br></div><div>                    npgSqlConnection.Close();</div><div>                }</div><div><br></div><div>            }</div><div>            catch (Exception exp)</div>
<div>            { };</div><div>        }</div><div><br></div><div>        public static pointObj Pixel2Geo(OSGeo.MapServer.pointObj pt, mapObj map)</div><div>        {</div><div>            // Converstion of pixel coordinates to Geographic coordinates</div>
<div>            int imgXMin, imgXMax, imgYMin, imgYMax;</div><div><br></div><div>            Double geoXMin, geoXMax, geoYMin, geoYMax;</div><div><br></div><div>            //init corner coords</div><div>            imgXMin = 0;</div>
<div><br></div><div>            imgYMin = 0;</div><div><br></div><div>            imgXMax = map.width;</div><div><br></div><div>            imgYMax = map.height;</div><div><br></div><div>            geoXMin = map.extent.minx;</div>
<div><br></div><div>            geoXMax = map.extent.maxx;</div><div><br></div><div>            geoYMin = map.extent.miny;</div><div><br></div><div>            geoYMax = map.extent.maxy;</div><div><br></div><div>            int imgWidth, imgHeight;</div>
<div><br></div><div>            System.Double geoWidth, geoHeight;</div><div><br></div><div>            //calc the width</div><div>            imgWidth = imgXMax - imgXMin;</div><div><br></div><div>            imgHeight = imgYMax - imgYMin;</div>
<div><br></div><div>            if (geoXMin &lt; geoXMax)</div><div>            {</div><div><br></div><div>                geoWidth = geoXMax - geoXMin;</div><div><br></div><div>            }</div><div>            else</div>
<div>            {</div><div><br></div><div>                geoWidth = geoXMin - geoXMax;</div><div><br></div><div>            }</div><div><br></div><div>            if (geoYMin &lt; geoYMax)</div><div>            {</div>
<div><br></div><div>                geoHeight = geoYMax - geoYMin;</div><div><br></div><div>            }</div><div>            else</div><div>            {</div><div><br></div><div>                geoHeight = geoYMin - geoYMax;</div>
<div><br></div><div>            }</div><div><br></div><div><br></div><div>            //calc the percent along each axis</div><div>            Double xPercent, yPercent;</div><div><br></div><div>            xPercent = pt.x / imgWidth;</div>
<div><br></div><div>            yPercent = pt.y / imgHeight;</div><div><br></div><div>            Double newX, newY;</div><div><br></div><div>            newX = (xPercent * geoWidth) + geoXMin;</div><div><br></div><div>            newY = geoYMax - (yPercent * geoHeight);</div>
<div><br></div><div>            return new OSGeo.MapServer.pointObj(newX, newY, 0.0, 0.0);</div><div><br></div><div>        }</div><div>    }</div><div><br></div><div><br></div><div>Thanks and Regards,</div><div><br></div>
<div>Ven</div></font></div>