简体   繁体   English

在leaflet.js地图上创建矩形网格

[英]Create a grid of rectangles on a leaflet.js map

如何将leaflet.js映射划分为矩形网格,以便为我单击的每个矩形触发一个不同的事件?

Get the height and width of the container in pixels, calculate appropriate dimensions for the amount of columns and rows you want, create rectangles of that size and add them to the map in a FeatureGroup, then attach a click handler to the featureGroup with .on . 获取容器的高度和宽度(以像素为单位),为所需的列和行的数量计算适当的尺寸,创建该尺寸的矩形并将其添加到FeatureGroup中的地图中,然后使用.on将单击处理程序附加到.on You will probably want to mark each rectangle's options object with some unique identifier. 您可能需要用一些唯一的标识符标记每个矩形的options对象。

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

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