Search code examples
androidarcgisarcgis-js-apiarcgis-server

arcGIS for android how to draw a crooked line?


My project meets a need to draw a curved path on the ArcGIS map But I used a lot of ways do not know how to draw a curved line in the code Ive tried multiple variations of this, but none of them seem to work. Any ideas?Thanks in advance.


Solution

  • Well, As I am understanding the requirement you want to add a curved line on the map using ArcGIS android sdk.

    First of all you you will be needed set of co-ordinates which you will be using to draw the line on the map.

    Polylines can be added to a graphics layer and displayed using a SimpleLineSymbol. This symbol allows you to display the graphic using one of a finite list of symbol types (dash, dash dot, dash dot dot, dot, null, or solid). You can further define the symbol by specifying a width and a color.

    Below are some samples of line symbols-

    enter image description here

    Once you have decided the line symbol styling use below code to add the line on the map.

    // create a line symbol (green, 3 thick and a dash style)
    SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Color.GREEN, 3, SimpleLineSymbol.STYLE.DASH);
    
    // create the line geometry
    Polyline lineGeometry = new Polyline();
    lineGeometry.startPath(-302557, 7570663);
    lineGeometry.lineTo(-302959, 7570868);
    lineGeometry.lineTo(-303042, 7571220);
    lineGeometry.lineTo(-302700, 7571803);
    lineGeometry.lineTo(-304043, 7576654);
    lineGeometry.lineTo(-300544, 7585289);
    lineGeometry.lineTo(-294365, 7592435);
    lineGeometry.lineTo(-290122, 7594445);
    lineGeometry.lineTo(-285283, 7595488);
    
    // create the graphic using the geometry and the symbol
    Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
    
    // add the graphic to the graphics layer
    graphicsLayer.addGraphic(lineGraphic);
    

    Output of above code

    enter image description here

    For more details your can refer ArcGIS android sdk...

    Hoping this will help you :)