AnsweredAssumed Answered

Create polygon through JSON with proper symbol

Question asked by rajni_sharma on Jul 29, 2020
Latest reply on Aug 4, 2020 by rajni_sharma

Hi i m naive to arcgis appstudio and trying to create multiple polygons through JSON set of vertices, i have my vetices in json format in db like below, but my geometry symbol do not support it.

Kindly guide in right direction.

Or my question could be like.. how to create a polygon through JSON data

import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.XmlListModel 2.0
import ArcGIS.AppFramework 1.0
import Esri.ArcGISRuntime 100.2
Item {
    //! [GOSymbols MapView]
    // Map view UI presentation at top
    MapView {
        id: mapView
        anchors.fill: parent
        rotationByPinchingEnabled: true
        zoomByPinchingEnabled: true
        Map {
            BasemapOceans {}
            initialViewpoint: viewPoint
        }
        GraphicsOverlay {
            id: graphicsOverlay
        }
    }
    //! [GOSymbols MapView]
    // the center of the mapview
    ViewpointCenter {
        id: viewPoint
        center: Point {
            x: 172.49307355493
            y: -43.4810759934974
            spatialReference: SpatialReference {
                wkid: 4326
            }
        }
        targetScale: 288895.277144
    }
    //! [GOSymbol line symbol]
    SimpleFillSymbol {
        id: fillSymbol
        style: Enums.SimpleFillSymbolStyleSolid
        color: Qt.rgba(1, 1, 0, 0.4)
        SimpleLineSymbol {
            style: Enums.SimpleLineSymbolStyleSolid
            color: "blue"
            width: 2.0
             antiAlias: true
        }
    }
    //! [GOSymbol line symbol]
    // add all the graphics to the graphics overlay
    Component.onCompleted: {
      // add boat route
        graphicsOverlay.graphics.append(createGraphic(createBoundaryRoute(), fillSymbol));
        // add the nesting ground
    }
    //! [GOSymbol createGraphic]
    // create and return a graphic
    function createGraphic(geometry, symbol) {
        var graphic = ArcGISRuntimeEnvironment.createObject("Graphic");
        graphic.geometry = geometry;
        graphic.symbol = symbol;
        return graphic;
    }
    //! [GOSymbol createGraphic]
    //! [GOSymbol createBoatRoute]
    // create the boat route
    function createBoundaryRoute() {
        // create polygine using json
        return ArcGISRuntimeEnvironment.createObject("Polygon", {"json": boundaryJson});
    }
    //! [GOSymbol createBoatRoute]
    //! [GOSymbol boatRouteJson]
    property var boundaryJson : {"paths":[[[172.49307355493, -43.4810759934974],
                                            [172.5030454523, -43.4334343434],
                                            [172.481307356908, -43.391075445974],
                                            [172.481307356908, -43.391075445974],
                                            [172.47307356908, -43.419075445974],[172.49307355493, -43.4810759934974]]],
                                  "spatialReference":{"wkid":4326}}
    //! [GOSymbol boatRouteJson]
}

Outcomes