0

I am using ArcGis API for JavaScript 3.18 and I wanted to make a simple map with multiple points that display a short description when I click on them but I have issue with defining multiple points on one GraphicLayer, my code for one PictureMarkerSymbol:

  map.on("load", function() {
         var gl = new GraphicsLayer();
         var p = new Point(19.466172, 51.774539);
         var s = new PictureMarkerSymbol('hat.png', 32, 32);
         var i = { Wydział: "Ekonomiczno-Socjologiczny", Adres: "Polskiej Organizacji Wojskowej 3/5, 90-255 Łódź", Telefon: "42 635 53 56"};
         var it = new InfoTemplate("EK-SOC");
         var g = new Graphic(p, s, i).setInfoTemplate(it);
        gl.add(g);
        map.addLayer(gl);
      });

How I can add more points to the (gl) Layer? I have tried with addMany function but it seems that's only for the newer API (4.1)

1 Answer 1

1

OK, I solved the issue, turns out it was a minor mistake with adding new point. The correct code looks like this:

map.on("load", function() {
         var s = new PictureMarkerSymbol('hat.png', 24, 24);

         var gl = new GraphicsLayer();
         var p = new Point(19.466172,51.774539);
         var i = { Wydział: "Ekonomiczno-Socjologiczny", Adres: "Polskiej Organizacji Wojskowej 3/5, 90-255 Łódź", Telefon: "42 635 53 56", www: "http://www.eksoc.uni.lodz.pl/"};
         var it = new InfoTemplate("Ekonomiczno-Socjologiczny");
         var g = new Graphic(p, s, i).setInfoTemplate(it);

         gl.add(g);

         var p2 = new Point(19.487214,51.775752);
         var i2 = { Wydział: "Zarządzania", Adres: "Jana Matejki 22/26, 90-237 Łódź", Telefon: "42 635 51 22", www: "http://www.wz.uni.lodz.pl/"};
         var it2 = new InfoTemplate("Zarządzania");
         var g2 = new Graphic(p2, s, i2).setInfoTemplate(it2);

        gl.add(g2);

 map.addLayer(gl);

I Hope that it will help someone!

0

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.