Last active
March 30, 2018 16:03
-
-
Save demiurg/e3ddc7fe95323b33cff24b868c7386f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function handleMousemove(vmap){ | |
| var self = this; | |
| self.event = null; | |
| self.highlight = function(e){ | |
| console.log(self.event); | |
| if (self.event != e){ | |
| return; | |
| } | |
| var features = vmap.queryRenderedFeatures(e.point, { | |
| layers: ['regions'] | |
| }); | |
| // Change the cursor style as a UI indicator. | |
| vmap.getCanvas().style.cursor = features.length ? 'pointer' : ''; | |
| // Remove things if no feature was found. | |
| if (!features.length) { | |
| return; | |
| } | |
| var feature = features[0]; | |
| vmap.setFilter( | |
| 'regions-highlight', | |
| ['==', 'id', feature.properties.id] | |
| ); | |
| } | |
| self.handler = function(e){ | |
| self.event = e; | |
| setTimeout(function(){ | |
| self.highlight(e); | |
| }, 1000); | |
| } | |
| return self.handler; | |
| } | |
| map.on('mousemove', handleMousemove(map)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment