Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing filters in casade or mutable vector tile features #977

Closed
alexmuro opened this issue Feb 4, 2015 · 1 comment
Closed

changing filters in casade or mutable vector tile features #977

alexmuro opened this issue Feb 4, 2015 · 1 comment

Comments

@alexmuro
Copy link

alexmuro commented Feb 4, 2015

I am trying to do a basic map where the feature I am hovering over changes color example

My approach so far is to make 2 layers in my source, 1 with all features from a vector source and 1 which is filtered to a single feature. Then I do this

  var currentFeature = {properties:{geoid:'23'}};
  map.on('hover', function(e) {
      map.featuresAt(e.point, {radius: 5}, function(err, features) {
          if (err) throw err;
          if(features[0]){
            if(currentFeature.properties.geoid !==  features[0].properties.geoid){
              style.layers[2].filter = ["==", "geoid", features[0].properties.geoid];
              map.setStyle(style);
              currentFeature = features[0]
            }
          }
      });
  });

This works but map.setStyle() takes way too long to re render the map to create a fluid effect.

I know I can edit the style in map.style.layerMap['layerid'] and I can change things in paint or paint.class and use cascade to get the map to update very quickly, however that doesn't help in this case.

Another approach would be to modify the feature's properties such that it complies with a preset filter but there is no setData() for vector tiles and modifying data regured by featuresAt() isn't effective.

Is it possible to put filters inside of the cascade refresh? Or is it possible to update vector tile data? What would be involved in implementing one of these features?

@jfirebaugh
Copy link
Contributor

Hi Alex -- the short answer is that there isn't a good way to do this right now. See #146 and #200 for issues tracking this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants