[GIS] ArcGIS JavaScript API: How to add a CSV as a Layer

arcgis-javascript-apiarcgis-server

I've created a map on ArcGIS online, adding a layer by uploading a csv file. This works fine, see map at link http://www.arcgis.com/home/webmap/vi…1ba43a0256c06b.

Now I'm trying to simulate this in JavaScript API. First I create a Web API service that returns the same data set I've got in csv file.
This is published on my local webserer. In my web page, I create a webmap, adding a layer that references this web API:

 function init() {
 var options = {
 basemap: "gray",
 center: [153.115672, -30.296312],
 zoom: 14
 }
 var mapServiceURL = "http://[myserver]/TRWDataManagerAPI/API/OzRegs";

 // Create map and call Init function
 map = new esri.Map("mapDiv", options);

 map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer(mapServiceURL));
 }
 dojo.ready(init);

The webmap is displayed, but the layer doesn't have any effect. What's missing? Am I at the right track? Your help is greatly appreciated.

Best Answer

You need to look at the three samples present here: CSV

If you look at the code, you will see that what they do, is to programmatically parse the CSV, and then add the data as graphics to the map.

There is no inbuilt class that will create a Layer for you from a CSV.