javascript - 我可以使用传单修改事件上标记图标的 CSS(使其更大)吗
问题描述
我实际上是在 Angular 服务中使用传单,我用这种方法生成我的标记图标:
private getIcon(geoJsonPoint) {
if (geoJsonPoint.properties.actif_id) {
const category = geoJsonPoint.properties.category.toUpperCase();
const prioritie = geoJsonPoint.properties.priority.toUpperCase();
const id = geoJsonPoint.properties.id;
console.log(geoJsonPoint);
const url = 'assets/images/' + category + '/' + prioritie + '.svg';
return L.icon({
iconUrl: url,
className: id,
iconSize: [58, 68],
iconAnchor: [29, 68],
popupAnchor: [0, -60]
});
所以在传单事件(popupen)上,我想让我的图标更大而不设置新图标,但只能修改 css。传单允许这种事情还是有人已经这样做了?
谢谢帮助!
解决方案
我设法使用 L.DomUtil 和 setTransform 解决了它,如果它可以帮助任何人,我会在下面发布代码。我准确地说我想在 popupopen 事件上转换图标。
private zoomIconOnPopupOpen(scale): void {
this.map.on('popupopen', (event1: any) => {
let marker = event1.popup._source;
if (marker._icon) {
const pos = L.DomUtil.getPosition(marker._icon);
L.DomUtil.setTransform(marker._icon, pos, scale);
}
});
this.map.on('popupclose', (event1: any) => {
let marker = event1.popup._source;
if (marker._icon) {
const pos = L.DomUtil.getPosition(marker._icon);
L.DomUtil.setTransform(marker._icon, pos, 1);
}
});
}
推荐阅读
- c++ - C++中无与伦比的组的位置是什么?
- python - 如何解决错误:h5py 构建轮子失败
- sql - 从 2 个表中,获取每个表唯一的行
- amazon-s3 - 现有 S3 存储桶的 Terraform 数据源在计划阶段尝试返回 NoSuchWebsiteConfiguration 的 GetBucketWebsite 请求失败
- sql - 将 2 列,同一个表链接到另一个表
- entity-framework-core - EF Core 自引用多对多双方
- python - 如何在 Python 中为多个变量快速添加 1?
- elasticsearch - 将日志 prestashop 发送到 kibana
- .net-core - 我可以做些什么来加快我使用 NBomber 的负载测试?(VS LT 250 RPS 轻松;NBomber 最高 25 RPS)
- python - 熊猫:将元素与另一个数据框进行比较