plot array of different pictureSymbol

313
1
Jump to solution
08-06-2020 04:51 AM
rsharma
Occasional Contributor III

Hi i am trying to add muliple picture marker symbol  in my app where x and y coordinates of different type of markers come from db like low signal and high signal

Now i am trying to add it in my map like below but it doesn't show up with markers

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
        }
        GraphicsOverlay{
            id:markergraphicOverlay
        }
    }    //! [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
}
    PictureMarkerSymbol {
        id:markersymbol
        url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae"
        width: 38.0
        height: 45.0
        offsetX: 0
        offsetY: 25
    }
    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
    // create each graphic type and then add them to the overlay at a time
    // alternatively you can create all of them and store in a list and add all of them
    // by calling appendAll and pass in the list.
    Component.onCompleted: {
        // add boat route
        graphicsOverlay.graphics.append(createGraphic(createBoundaryRoute(), fillSymbol));
        markergraphicOverlay.graphics.append(createGraphic(addMarker(), markersymbol));
        // 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;
        console.log((graphic.geometry.json));
        return graphic;
    }
    //! [GOSymbol createGraphic]
    //! [GOSymbol createBoatRoute]
    // create the boat route
    function createBoundaryRoute() {
        // create polyline using json
        return ArcGISRuntimeEnvironment.createObject("Polygon", {"json": boundaryJson});
    }
    //! [GOSymbol createBoatRoute]
    function addMarker(){
         return ArcGISRuntimeEnvironment.createObject("Point",{"x":172.49307355493,"y": -43.4810759934974, "spatialReference": { wkid: 4326 } });
     }
    //! [GOSymbol boatRouteJson]
    property var boundaryJson : {"rings":[[[172.4864177167, -43.4807531333], [172.4947915167, -43.4814620167], [172.4942547333, -43.4809051667], [172.4937289833, -43.4799734], [172.4935005833, -43.4796536333], [172.4934417167, -43.4795711167], [172.486064, -43.4807159833], [172.4860340333, -43.4807206667], [172.4864177167, -43.4807531333]]],
                                  "spatialReference":{"wkid":4326}}
    //! [GOSymbol boatRouteJson]
}

					
				
			
			
				
			
			
				
0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I see an issue in your addMarker function. Point's spatialReference property expects a SpatialReference object, but the way you've got it, it passes in a json of wkid: 4326. Try instead:

return ArcGISRuntimeEnvironment.createObject("Point",{"x":172.49307355493,"y": -43.4810759934974, "spatialReference": SpatialReference.createWgs84() });


Or

const sr = ArcGISRuntimeEnvironment.createObject(“SpatialReference”, { “wkid”: 4326};

return ArcGISRuntimeEnvironment.createObject("Point",{"x":172.49307355493,"y": -43.4810759934974, "spatialReference": sr });

View solution in original post

1 Reply
LucasDanzinger
Esri Frequent Contributor

I see an issue in your addMarker function. Point's spatialReference property expects a SpatialReference object, but the way you've got it, it passes in a json of wkid: 4326. Try instead:

return ArcGISRuntimeEnvironment.createObject("Point",{"x":172.49307355493,"y": -43.4810759934974, "spatialReference": SpatialReference.createWgs84() });


Or

const sr = ArcGISRuntimeEnvironment.createObject(“SpatialReference”, { “wkid”: 4326};

return ArcGISRuntimeEnvironment.createObject("Point",{"x":172.49307355493,"y": -43.4810759934974, "spatialReference": sr });