Select to view content in your preferred language

Use turf for bezier the line?

879
1
07-16-2017 09:58 PM
PutriDewi_Purnamasari
Deactivated User

I'm planning to apply turf to bezier the line. The line has been stated before, but seems like the line isn't rendered to curved.

Let's check out my code.

//======= Load data Polyline ==========
          var line = new Polyline(wgs84);
          var b = 0;
          var a = 0;
             // console.log(hasilarray);
          arrayUtils.forEach(hasilarray, function(ple){
            // console.log();
            if(a==0){
              var jumlah = akhir.length;
              for(c=0;c<jumlah;c++){
                var load = JSON.stringify(hasilarray[0][c]);
                console.log(load +" jalur "+c);
                var jumlah_k = hasilarray[0][c].length;
                for(d=0;d<jumlah_k;d++){
                  // array_koordinat.push(hasilarray[0]);
                  var koor_x_p = hasilarray[1][d][0].toString();
                  var koor_y_p = hasilarray[1][d][1].toString();
                  var x_ = Number(koor_x_p);
                  var y_ = Number(koor_y_p);
                  array_koordinat.push(x_,y_);
                  koordinat_a.push(array_koordinat);
                  array_koordinat=[];
                }
                line.addPath(hasilarray[0][c]);
              }
            }else{
              var load = JSON.stringify(hasilarray[1]);
              // console.log(JSON.stringify(hasilarray[1]));
              //console.log(load +" jalur terakhir");
              var jumlah_k = hasilarray[1].length;
              for(e=0;e<jumlah_k;e++){
                  var koor_x_p = hasilarray[1][e][0].toString();
                  var koor_y_p = hasilarray[1][e][1].toString();
                  var x_ = Number(koor_x_p);
                  var y_ = Number(koor_y_p);
                  array_koordinat.push(x_,y_);
                  koordinat_a.push(array_koordinat);
                  array_koordinat=[];
                }
              // array_koordinat.push(hasilarray[1]);
              line.addPath(hasilarray[1]);


            }
            a++;
            b++;
          }) ;


          console.log(JSON.stringify(koordinat_a));




         /* var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0,0.5]),3);      
          map.graphics.add(new esri.Graphic(line, lineSymbol));*/


          var bg = new Graphic(line, basicSymbol, {}, null);


                    graphicsLayer.add(bg);


                    showEndSymbol.push(basicSymbol);      

Where should I put the turf bezier function so it can be showed and rendered on the view? Thanks.

0 Kudos
1 Reply
ThomasSolow
Frequent Contributor

Can you share what the paths for this line look like after the graphic has been created?

ie: console.log(JSON.stringify(bg.geometry));

0 Kudos