[Issue] Filter featurelayer

229
0
11-14-2019 01:34 AM
JelleToonen
New Contributor

Hello,

Since monday I am trying to get a part of a featurelayer on the map where you can press a button to turn it on or off. Sadly I cant manage finding a solution also my friend that knows alot about javascript could not figure it out so I am here.

    ready(function () {

        // Parse DOM nodes decorated with the data-dojo-type attribute
        parser.parse();


        // Specify the initial extent
        var extentInitial = new Extent({
            "xmin": 1579648.2164843145,
            "ymin": 4274917.731945126,
            "xmax": 1622327.2260456155,
            "ymax": 4311416.913197627,
            "spatialReference":{
                "wkid":102100,
                "latestWkid":3857}
        });

        mapMain = new Map("cpCenter", {
            basemap : "satellite",
            extent : extentInitial,
        });

        let popUp = new PopupTemplate({
            "title": "{name}",
            "description" : "type : {category} <br> phone : {phone} <br> address : {address}"

        });


        let featureLayer = new FeatureLayer("http://10.10.0.65:6080/arcgis/rest/services/Geosys_test_noSec/Dev_test/FeatureServer/0", {
            infoTemplate : popUp,
            outFields: ["*"],
        });


        let query = new Query();
        query.where = "category = 'barsWineBarPub'";
        query.outFields = ["*"];
        query.returnGeometry = true;


        let categoryFeaturesQuery;
        featureLayer.queryIds(query, function(categoryIds) {
            console.log(categoryIds);
            categoryFeaturesQuery = new Query();
            categoryFeaturesQuery.outFields = ["*"];
            categoryFeaturesQuery.objectIds=  categoryIds;


            featureLayer.queryFeatures(categoryFeaturesQuery, function(categoryFeatureSet) {

                filterino = featureLayer;
                filterino.filter = {
                    where: "SELECT objectid IN (" + categoryIds + ")"
                };
                mapMain.addLayers([filterino]);
                test = categoryFeatureSet.features;
                console.log(filterino);

            });

        });

        let basemapGallery = new BasemapGallery({

            map : mapMain

        }, "basemapGallery");
        basemapGallery.startup();

        mapMain.on("layers-add-result", function () {
            let dijitLegend = new Legend({
                map: mapMain,
            }, "divLegend");
            dijitLegend.startup();

            document.getElementById('buttonTest').onclick = function() {
                // access properties using this keyword
                if (this.checked) {

                } else {

                }
            };
        });


    });
});

This is the code I´m Working on. I tried using a query to get the data from catagory BarsandWinePubs. I get the Objectid of them but I cant filter them so they are the only one seen on the map It still loads everything in like without filter.

Is the filter not working? or is the query wrong? or am I doing it wrong completly?

kind regards,

Jelle

Student

0 Kudos
0 Replies