我使用传单在地图中绘制了一个矩形标记。当我放大地图时,矩形标记会自动变大。但我不想要那个。我希望标记的宽度可以增加,但标记的高度应该保持不变。我怎么能在传单中这样做?这是我的代码
map2.setView([outputf[0].lat,outputf[0].lon], 9);
// Code to rectange
var latLng = L.latLng(outputf[0].lat, outputf[0].lon);
var currentPoint = map2.latLngToContainerPoint(latLng);
var W = 20;
var H = 12*map2.getZoom()/9;
var xDifference = W / 2;
var yDifference = H / 2;
var southWest = L.point((currentPoint.x - xDifference), (currentPoint.y - yDifference));
var northEast = L.point((currentPoint.x + xDifference), (currentPoint.y + yDifference));
var bounds = L.latLngBounds(map2.containerPointToLatLng(southWest),map2.containerPointToLatLng(northEast));
L.rectangle(bounds,{color: "black", opacity:.6, weight: 2,fillColor: "red",id:dir}).bindPopup('WorkZone is: '+output[ax].key).addTo(map2).on('click', onClick);
W表示宽度,H表示矩形的高度。我正在尝试
var H = 12*map2.getZoom()/9;
但它根本不起作用。