更改传单中标记的大小 [英] change size of marker in leaflet

查看:97
本文介绍了更改传单中标记的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在传单中的地图上有一个标记:

I have one marker on the map in leaflet:

var centerMarker = L.marker(centerPoint, { title: 'unselected' }).bindLabel(schools[i][0]);
centerMarker.on('click', selectMarker);
centerMarker.addTo(map);

我想在点击时更改该标记的大小.

I want to change the size of that marker on click.

我知道我们可以更改图标,但是我只想更改标记中相同图标的大小.

I know that we can change icons but I just want to change the size of the same icon of the marker.

推荐答案

您可以从标记本身获取旧图标,更改图标的大小,然后使用更改后的图标调用setIcon:

You can get the old icon from the marker itself, change the size of the icon and then call setIcon with the changed icon:

var icon = centerMarker.options.icon;
icon.options.iconSize = [newwidth, newheight];
centerMarker.setIcon(icon);

这篇关于更改传单中标记的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆