TransWikia.com

Placing symbol at map extent center

Geographic Information Systems Asked by Rpandia31 on September 1, 2021

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 September 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP