Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have created map using ArcGIS Server in C#. I need to display points as a graphic. my database consists of points lat lon values,

xval                  yval                  txnid    attr1   attr2
772680.3173976026     1452862.4585646628      1       -        -
773043.7099894881     1453188.5279139602      2        -       -

Similarly I have around 5K of rows. I need to display it on my map.

The aspx code for map,

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>OnCliCkPoint</title>
</head>
<script type="text/javascript">
var djConfig = {
    parseOnLoad: true
};
</script>
<script src="JavaScript/MapJavascriptV2.js" type="text/javascript"></script>
<script src="JavaScript/LoadMap.js" type="text/javascript"></script>
<script src="JavaScript/TOC.js" type="text/javascript"></script>
<script src="JavaScript/ConvertXYToLatLong.js" type="text/javascript"></script>
<body>
<form id="form1" runat="server">
    <div>
        <div id="mapDiv" style="border: 1px solid Blue; width: 100%; height: 100%; overflow: hidden; padding: 2px;">
        </div>
    </div>
</form>
</body>
</html>

The CS code for map and also for calling points from SQL Server 2008

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OnClickPoint : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
    SqlConnection Conn = new SqlConnection("Data Source=XXX.XXX.X.XXX\\tfs;Initial Catalog=TGR;Uid=XX;Password=XXXXXXXX");
    //Conn.Open();

    SqlCommand cmd = new SqlCommand("SP_SelectAllXY", Conn);
    cmd.CommandType = CommandType.StoredProcedure;
    DataTable dt = new DataTable();
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    da.Fill(dt);

    string[] xy = new string[dt.Rows.Count];
    for (int i = 0; i < dt.Rows.Count; i++)
    {
        xy[i] = dt.Rows[i][0].ToString() + "," + dt.Rows[i][1].ToString();
    }
    ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "zoom", "drawpointsView(" + xy + ");", true);

}
}

The LoadMap.js javascript used to load map,

dojo.require("esri.map");

var map, zoominMap;
function init() {

map = new esri.Map("mapDiv");

dojo.connect(map, 'onLoad', function (map) {
    dojo.connect(dijit.byId('mapDiv'), 'resize', resizeMap);

});

zoominMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://XXX.XXX.Z.XXX/ArcGIS/rest/services/XXXXXX/MapServer");
map.addLayer(zoominMap);
}

function resizeMap() {
var resizeTimer;
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
    map.resize();
    map.reposition();
}, 500);
}

function ShowDetails() {
var divDetails = document.getElementById("divDetails");
if (divDetails.style.display == "none") {
    divDetails.style.display = "";
}
else {
    divDetails.style.display = "none"
}
}

function onRowClickHandler(evt) {
var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID;
var selectedTaxLot;

dojo.forEach(map.graphics.graphics, function (graphic) {
    if ((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId) {
        selectedTaxLot = graphic;
        return;
    }
});
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
}
function drawpointsView(xycoordinates) {
if (map.getLayer('highlightedPoints') != null) {
    map.getLayer('highlightedPoints').clear();
}
var highlightedPoints = new esri.layers.GraphicsLayer({ id: "highlightedPoints" });
for (var i = 0; i < xycoordinates.length; i++) {
    var graphic = new esri.Graphic(new esri.geometry.Point(xycoordinates[i][0], xycoordinates[i][1], map.spatialReference),
                  new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 8,
                  new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
                  new dojo.Color([255, 0, 0]), 2),
                  new dojo.Color([255, 0, 0, 0.25])));

    highlightedPoints.add(graphic);
}
map.addLayer(highlightedPoints);
}
dojo.addOnLoad(init);

The map is loading correctly but, I am not getting the points.

I am not getting where I went wrong. Thanks in advance..

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.