Select to view content in your preferred language

fade map outside polygon geometry

4225
8
Jump to solution
08-11-2020 12:31 AM
rsharma
Frequent Contributor

Hi i want fade my map outside its geometry like i have done javascript api like in the link.

Query : How to create the gray area over the extent expand to 10 so that i will perform difference between geometry and the extent

Geometry difference(Geometry geometry1, Geometry geometry2)

I want to do it same in qt sdkFade back map outside of polygon 

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

An simple solution might be to just buffer the geometry by whatever distance you want. https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-geometryengine.html...

View solution in original post

0 Kudos
8 Replies
rsharma
Frequent Contributor

Hi guys can anyone help me in this task, as it is quite intricate for me to plot gray area outside polygons and then get difference of them

0 Kudos
LucasDanzinger
Esri Frequent Contributor

You can accomplish this by adding a Polygon graphic that has a hole in it.

Here is an example where I have a multipart polygon - one part has 4 points and the other has 4 as well. The interior part goes in counter clockwise order and is shown as a hole. This is described in the REST specs a bit for ArcGIS as a whole - Geometry objects—Common Data Types | ArcGIS for Developers 

MapView {
    id: mv
    anchors.fill: parent
    Map {
        BasemapImagery{}
    }

    GraphicsOverlay {
        Graphic {
            symbol: SimpleFillSymbol {
                color: Qt.rgba(0,0,0,.75);

            }
            geometry: Polygon {
                json:  {"rings":[[[-18684976.52965096,13174661.735383898],[11421379.755389877,11822129.922245625],[13775786.985667616,-9517816.462824922],[-18384413.904509123,-8215378.42054362],[-18684976.52965096,13174661.735383898]],[[-1202250.5005673468,3907314.1268438715],[601125.2502836883,4057595.4394147918],[651219.0211406611,5860971.190265823],[-1603000.667423129,5760783.648551878],[-1202250.5005673468,3907314.1268438715]]],"spatialReference":{"latestWkid":3857,"wkid":102100}}
            }
        }
    }        
}

To keep this code concise, I just defined it in JSON, but you could use the PolygonBuilder class and add several parts to it. Each part should contain points. The order defined will be important for making it topologically sound and display as you desire

0 Kudos
rsharma
Frequent Contributor

I am trying it this way and is succeed also and

want to expand graphics of overlayGray to some more km distance from my extent, can u help me how to expand it:my extent

Here in  getExtentEnvelope() i counted the xmin xmax etc values manually, so the polygon appears on my whole screen. The pictures i attached below are some zoomed out images.

 Component.onCompleted: {
var overlaygeometry='';
       // add the polygon
        var rings = userMap.getpolygon;//boundaries from db
            graphicsOverlay.graphics.append(createGraphic(createPolygon(rings), fillSymbol));
             overlaygeometry=GeometryEngine.difference(getExtentEnvelope(), createPolygon(rings));
        graphicsOverlay.graphics.append(createGraphic(overlaygeometry, overlayGray));          
    }//End components.loaded
 SimpleFillSymbol{
        id:overlayGray
        style: Enums.SimpleFillSymbolStyleSolid
        color: Qt.rgba(1,1,0,0.2)
     }
function getExtentEnvelope(){
         const sr = ArcGISRuntimeEnvironment.createObject("SpatialReference", { "wkid": 4326});
        return ArcGISRuntimeEnvironment.createObject("Envelope", { xMin: xMinVal, yMin: yMinVal, xMax: xMaxVal, yMax: yMaxVal, spatialReference:sr});
     }
   function createGraphic(geometry, symbol) {
        var graphic = ArcGISRuntimeEnvironment.createObject("Graphic");
        graphic.geometry = geometry;
        graphic.symbol = symbol;
        return graphic;
    }//end createGraphic
function createPolygon(ring) {
        // create polygon using json
         const sr = { "wkid": 4326};
         var boundaryJson = {"rings":ring,"spatialReference":sr};
         var boundary= ArcGISRuntimeEnvironment.createObject("Polygon", {"json": boundaryJson});
        return boundary;
    }
0 Kudos
rsharma
Frequent Contributor

Lucas Danzinger‌ Is this task still on your list, i just want help with extent expamsion to some few kms, Can u. help me for it.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

No, I don't understand what you are trying to accomplish. 

0 Kudos
rsharma
Frequent Contributor

Hi I am trying to accomplish like this picture first make difference of 2 geometries then expand the extent of gray color to few kms

I have made geometry difference but does not know how to expand the gray color extent

function getExtentEnvelope(){
      const sr = ArcGISRuntimeEnvironment.createObject("SpatialReference", { "wkid": 4326});
     return ArcGISRuntimeEnvironment.createObject("Envelope", { xMin: xMinVal, yMin: yMinVal, xMax: xMaxVal, yMax: yMaxVal, spatialReference:sr});
     }
with this the code gray color shows only to its extent limits. 
WHole code is in previous conversation of this thread

0 Kudos
LucasDanzinger
Esri Frequent Contributor

An simple solution might be to just buffer the geometry by whatever distance you want. https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-geometryengine.html...

0 Kudos
rsharma
Frequent Contributor

Thanks thats what i was looking for

0 Kudos