forEachFeatureAtPixel not limiting features?Using OpenLayers 3 forEachFeatureAtPixel to specify layer?Make...

How to pivot a dataframe with two columns with no index

Is there some relative to Dutch word "kijken" in German?

If I delete my router's history can my ISP still provide it to my parents?

Placing an adverb between a verb and an object?

How do you funnel food off a cutting board?

Can a person refuse a presidential pardon?

Can you combine War Caster, whip, and Warlock Features to Eldritch Blast enemies with reach?

The effects of magnetism in radio transmissions

What is the in-universe cost of a TIE fighter?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

What's a good word to describe a public place that looks like it wouldn't be rough?

Checking for the existence of multiple directories

Citing paywalled articles accessed via illegal web sharing

Why did this image turn out darker?

Word or phrase for showing great skill at something without formal training in it

We are very unlucky in my court

Slow moving projectiles from a hand-held weapon - how do they reach the target?

What is a jet (unit) shown in Windows 10 calculator?

What is the wife of a henpecked husband called?

Am I a Rude Number?

A minimum of two personnel "are" or "is"?

Avoiding morning and evening handshakes

Disable the ">" operator in Rstudio linux terminal

Typing Amharic inside a math equation?



forEachFeatureAtPixel not limiting features?


Using OpenLayers 3 forEachFeatureAtPixel to specify layer?Make only particular features on layer selectableUsing forEachFeatureAtPixel without mouseOpenlayers 3 - get Geometry of a VectorTile to highlight featuresOpenLayers: Finding features in pixels radiusOpenlayers3, vector data layer not visible after proceeding select onchange functionExcluding several layers from forEachFeatureAtPixel function using OpenLayers 3?Pgrouting PHP don't work with Openlayers and GeoExtError loading geoJSON into map using OpenLayers v4.2.0Limiting OpenLayers heatmap to vector feature boundaries













2















I'm trying to limit the features returned when I click on the map to just those in the endPoint layer:



    endPoint = new ol.layer.Vector({
source: new ol.source.Vector({
features: endPoints //add an array of features
}),
});
map.addLayer(endPoint)


Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?



Is the issue that I need to name the layer somehow?



    map.on('click', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
}, null, function(layer) {
return layer === endPoint;
});
console.log(mapFeature)
})









share|improve this question

























  • Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

    – htulipe
    Feb 4 '15 at 18:59


















2















I'm trying to limit the features returned when I click on the map to just those in the endPoint layer:



    endPoint = new ol.layer.Vector({
source: new ol.source.Vector({
features: endPoints //add an array of features
}),
});
map.addLayer(endPoint)


Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?



Is the issue that I need to name the layer somehow?



    map.on('click', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
}, null, function(layer) {
return layer === endPoint;
});
console.log(mapFeature)
})









share|improve this question

























  • Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

    – htulipe
    Feb 4 '15 at 18:59
















2












2








2








I'm trying to limit the features returned when I click on the map to just those in the endPoint layer:



    endPoint = new ol.layer.Vector({
source: new ol.source.Vector({
features: endPoints //add an array of features
}),
});
map.addLayer(endPoint)


Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?



Is the issue that I need to name the layer somehow?



    map.on('click', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
}, null, function(layer) {
return layer === endPoint;
});
console.log(mapFeature)
})









share|improve this question
















I'm trying to limit the features returned when I click on the map to just those in the endPoint layer:



    endPoint = new ol.layer.Vector({
source: new ol.source.Vector({
features: endPoints //add an array of features
}),
});
map.addLayer(endPoint)


Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?



Is the issue that I need to name the layer somehow?



    map.on('click', function(evt) {
var pixel = map.getEventPixel(evt.originalEvent);
var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
return feature;
}, null, function(layer) {
return layer === endPoint;
});
console.log(mapFeature)
})






openlayers






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 mins ago









PolyGeo

53.6k1780240




53.6k1780240










asked Feb 3 '15 at 19:20









JakeJake

112




112













  • Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

    – htulipe
    Feb 4 '15 at 18:59





















  • Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

    – htulipe
    Feb 4 '15 at 18:59



















Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

– htulipe
Feb 4 '15 at 18:59







Your message is unclear. What is your bug exactly? Do you have features of other layers that pass the filter function? That should not be the case, your usage of the method is good. No others features than the ones belonging to endpoint should pass the filter (put a debugger breakpoint to verify this). Something else in your code must be the cause of this problem.

– htulipe
Feb 4 '15 at 18:59












1 Answer
1






active

oldest

votes


















1














I do my info function this way.



wmsLayer09 is the layer where I want the click search for features, so I only get features from that layer



var feature = map.forEachFeatureAtPixel(evt.pixel,
function (feature, wmsLyr09) {
return feature;
});





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f132953%2fforeachfeatureatpixel-not-limiting-features%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I do my info function this way.



    wmsLayer09 is the layer where I want the click search for features, so I only get features from that layer



    var feature = map.forEachFeatureAtPixel(evt.pixel,
    function (feature, wmsLyr09) {
    return feature;
    });





    share|improve this answer




























      1














      I do my info function this way.



      wmsLayer09 is the layer where I want the click search for features, so I only get features from that layer



      var feature = map.forEachFeatureAtPixel(evt.pixel,
      function (feature, wmsLyr09) {
      return feature;
      });





      share|improve this answer


























        1












        1








        1







        I do my info function this way.



        wmsLayer09 is the layer where I want the click search for features, so I only get features from that layer



        var feature = map.forEachFeatureAtPixel(evt.pixel,
        function (feature, wmsLyr09) {
        return feature;
        });





        share|improve this answer













        I do my info function this way.



        wmsLayer09 is the layer where I want the click search for features, so I only get features from that layer



        var feature = map.forEachFeatureAtPixel(evt.pixel,
        function (feature, wmsLyr09) {
        return feature;
        });






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 7 '15 at 15:20









        Juan Carlos OropezaJuan Carlos Oropeza

        2591214




        2591214






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f132953%2fforeachfeatureatpixel-not-limiting-features%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

            Meter-Bus Содержание Параметры шины | Стандартизация |...