AnswerBun.com

Placing symbol at map extent center

Geographic Information Systems Asked on January 5, 2022

I am using ArcGIS Web AppBuilder (Version 2.13 August 2019).

I have a widget, and on button click, I need to place a symbol at the centre of the map.

I tried using :

selectFeatureService: function (value) {
    value = Number(value);
    if (this.overviewLayer) {
        this.map.removeLayer(this.overviewLayer);
        this.overviewLayer = null;
    }
    this.graphicExists = false;
    //this.allCoverage.set("checked", false);
    this.map.graphics.clear();
    this.imageDialog.hide();
    ***var ctrPt = this.map.center;
    console.log("center Point found(X) :"+ctrPt.x);
    console.log("MinX: " + this.map.extent.XMin + "n");
    console.log("MinY: " + this.map.extent.YMin + "n");
    console.log("MaxX: " + this.map.extent.XMax + "n");
    console.log("MaxY: " + this.map.extent.YMax + "n");***
    if (value !== "select") {
        var url = this.config.oic[value].serviceUrl;
        if (url.indexOf("ImageServer") === -1) {
            var query = new Query();
            query.where = "1=1";
            query.returnGeometry = false;
            query.outSpatialReference = this.map.extent.spatialReference;
            var queryTask = new QueryTask(url);
            queryTask.executeForExtent(query, lang.hitch(this, function (response) {
                if (response.extent) {
                    this.map.setExtent(response.extent);
                }
            }));
        } else {
            var request = new esriRequest({
                url: url,
                content: {
                    f: "json"
                },
                "handleAs": "json",
                "callbackParamName": "callback"
            });
            request.then(lang.hitch(this, function (response) {
                if (response && response.extent) {
                    if (response.extent.spatialReference.wkid === this.map.spatialReference.wkid)
                        this.map.setExtent(new Extent(response.extent));
                    else {
                        var params = new ProjectParameters();
                        params.geometries = [new Extent(response.extent)];
                        params.outSR = new SpatialReference(this.map.spatialReference.wkid);
                        this.geometryService.project(params, lang.hitch(this, function (geometry) {
                            this.map.setExtent(geometry[0]);
                        }));
                    }
                }
            }));
        }
        if (this.config.oic[value].overviewUrl) {
            this.overviewLayer = this.layerModuleSelector(this.config.oic[value].overviewUrl);
            this.map.addLayer(this.overviewLayer);
        }
    }
},

Where am I going wrong?

One Answer

it turns out WAB is still in 3.X, so the error I was doing was: this.map.extent.getCenter();

Answered by Rpandia31 on January 5, 2022

Add your own answers!

Related Questions

Adding GeoPandas Dataframe to PostGIS table?

4  Asked on March 20, 2021 by thecornman

     

Splitting raster into smaller chunks using GDAL?

6  Asked on March 20, 2021 by chad-cooper

         

Plotting proportional symbol map of horse mackerel species using R

0  Asked on March 20, 2021 by ibrahim-al-anboori

       

Get data from SoilGrid

0  Asked on March 19, 2021 by andriy-hertz

   

ArcGIS Online Routing – Multiple route end stops?

0  Asked on March 19, 2021 by ohh_danielson

   

Adding color to polylines in leaflet in R

1  Asked on March 19, 2021 by dhiraj

   

Parsing WFS write transaction response in OpenLayers

1  Asked on March 19, 2021 by marcus-junius-brutus

   

Qgis – Labels automatically resize to fit within the polygon

1  Asked on March 19, 2021 by manoel-guedes

     

Install QGIS Dev on Ubuntu or WSL

0  Asked on March 19, 2021 by dror-bogin

     

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir