简体   繁体   English

使用Mapbox或Leaflet突出显示多边形

[英]Polygon highlighting with Mapbox or Leaflet

I am trying to replicate polygon highlighting on mouseover event in mapbox.js or leaflet.js similar to the example below: 我正在尝试在mapbox.js或leaflet.js中的mouseover事件上复制多边形突出显示,类似于以下示例:

http://projects.nytimes.com/census/2010/explorer?view=raceethnicity&lat=40.6311&lng=-73.994&l=12 http://projects.nytimes.com/census/2010/explorer?view=raceethnicity&lat=40.6311&lng=-73.994&l=12

How does this work? 这是如何运作的?

Using Leaflet, you simply have to define a function to set the style of the polygon on mouseover event. 使用Leaflet,您只需定义一个函数即可在mouseover事件上设置多边形的样式。 For example: 例如:

polygonLayer.on('mouseover', function (this) {
    this.setStyle({
        fillOpacity: 0,
        color: 'black'
        });
});

You can create a per-feature hover effect by using events and feature states of Mapbox GL JS. 您可以使用Mapbox GL JS的事件和功能状态来创建按功能悬停的效果。

Follow this link for implementation! 请点击此链接进行实施!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM