0

I am trying to add a different map marker for every lat/long point added through a csv file using CSV Layer,is it possible to loop through each of the point for which I am going to add map marker and add a different map marker for those points.

I am having a CSV file that contains lat/long and other information such as device_type for various electronic devices such as below:

latitude,longitude,device_type

28.7041,77.1025,device_1

26.8541,76.8965,device_1

27.7844,79.7974,device_2

26.7041,76.1025,device_2

On the basis of device type,I want to create a different map marker and plot it on map,like for the device_1,I want to create one type of map marker and for the device_2,I want to have a different map marker.Is it possible to do so?

    addCSVLayer = function (){
        // Importing csv file
            var url =
            "http://localhost/Geocoding_Report.csv";
            var template = {
            title: "Device Info",
            content: "Device type {device_type}"
            };

            csvLayer = new CSVLayer({
                url: url,
                popupTemplate: template,
            });

            csvLayer.renderer = {
                type: "simple", // autocasts as new SimpleRenderer()
                symbol: {
                  type: "picture-marker",  // autocasts as new PictureMarkerSymbol()
                  url: "http://localhost/fibrenode.png",
                  width: "25px",
                  height: "25px"
                }
              };
            map.add(csvLayer);
        }
    }
3
  • can you provide what have you tried in javascript?
    – Mapperz
    May 2, 2018 at 13:50
  • I have tried the same code written above in javascript i.e addCSVLayer function written above : But with this above code, all the map marker that are getting plotted on map are same,but I want to plot different map marker on the basis of device type .
    – Amit Chand
    May 3, 2018 at 5:54
  • If this is going to be a regular thing you do you could create a shapefile/layer with the specific symbology you want ahead of time. Then when you add your csv file and display XY coordinates you can apply symbology from layer, using the layer your previously created (upload the layer, run the tool, remove layer). May 14, 2018 at 20:57

1 Answer 1

1

Here is a sample that does what you are after: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=layers-csv-projection

SimpleRenderer displays all the points with the same symbol. You need a UniqueValueRenderer to display different symbols based on an attribute. You can read more about visualization techniques with the ArcGIS API for JavaScript here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.