Create polygon through JSON with proper symbol

219
3
Jump to solution
07-29-2020 11:42 PM
rsharma
Occasional Contributor III

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]
}

					
				
			
			
				
			
			
				
0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Everything in ArcGIS Runtime that can go to/from JSON is based on the ArcGIS REST spec. 

So for geometries, you can reference this doc - Geometry objects—Common Data Types | ArcGIS for Developers 

For symbols, Symbol Objects—Common Data Types | ArcGIS for Developers  

View solution in original post

3 Replies
ErwinSoekianto
Esri Regular Contributor

I am going to tag ArcGIS Runtime SDK for Qt‌ to see if anyone in that group knows the json format to create Polygon. 

I think this must be related to how the json is supposed to be formatted. 

LucasDanzinger
Esri Frequent Contributor

Everything in ArcGIS Runtime that can go to/from JSON is based on the ArcGIS REST spec. 

So for geometries, you can reference this doc - Geometry objects—Common Data Types | ArcGIS for Developers 

For symbols, Symbol Objects—Common Data Types | ArcGIS for Developers  

View solution in original post

rsharma
Occasional Contributor III

Thanks i was using paths in attributes instead of rings

0 Kudos