AnsweredAssumed Answered

Overlay Point from local text file

Question asked by geonetadmin on Apr 19, 2010
Latest reply on Apr 19, 2010 by geonetadmin
Original User: khayer

I have a CSV file which contains lat,lon,ID fields. I want to read the csv and add those point as new graphics layer. Read the csv using javascript is not problem. But i can add those point to map using ESRI javascript which i can do very easily by google map api. Below i mention my code,

      function init() {
 
       var startExtent = new esri.geometry.Extent(-102.5,36.8,-99.8,38.4, new    esri.SpatialReference({wkid:4326}) );
      
       var map = new esri.Map("map", {extent:startExtent});

        var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
        map.addLayer(tiledMapServiceLayer);
 
  //Create graphics layer for counties
          var countyLayer = new esri.layers.GraphicsLayer();
         
  var lat=null
  var lon=null;

  var markerSymbol = new esri.symbol.PictureMarkerSymbol("flagNormal.png", 30, 30);
  
  var atts = {};
  atts["ID"] = 1;
     
  lat=37.514;
  lon=-101.1719;
  var location = new esri.geometry.Point(lon, lat, new esri.SpatialReference({wkid:4326}));
  var graphic = new esri.Graphic(location, markerSymbol, atts);
  graphic.titleField = "ID";
 
  countyLayer.add(graphic);
 
  map.addLayer(countyLayer);
      }

Here, map can not add new graphic layer. i have tested map.graphics that is always null. I have also tested the code for both 2.0 and 1.6. But i is failed to load graphics. Do i am in right track? Is there other alternative to do this kind of task?

Thanks
Khayer
GIS developer,
CEGIS,
Bangladesh

Outcomes