change default icon toolbar (Leaflet)

走远了吗. 提交于 2019-12-07 18:11:51

问题


how can i change default toolbar icon to something else on leaflet..

picture above show the default view of icon.. i want to customize and change the icon to something else for example the first icon i want to look like as a bridge and second text icon and so on..

i already tried a few ways but did not work.

here my code

var electricpole = L.Icon.extend({
        options: {
            shadowUrl: null,
            iconAnchor: new L.Point(12, 12),
            iconSize: new L.Point(30,30),
            iconUrl: 'image/electricpole.png'
        }
    });

L.DrawToolbar.include({
        getModeHandlers: function(map:L.Map) {
            return [
                {
                    enabled: true,
                    handler: new L.Draw.Polyline(map),
                    title: 'Draw Polyline'
                },
                {
                    enabled: true,
                    handler: new L.Draw.Polygon(map),
                    title: 'Draw Polygon'
                },
                {
                    enabled: true,
                    handler: new L.Draw.Rectangle(map),
                    title: 'Draw Rectangle'
                },
                {
                    enabled: true,
                    handler: new L.Draw.Circle(map),
                    title: 'Draw Circle'
                },
                {
                    enabled: true,
                    handler: new L.Draw.Marker(map, {
                      icon: new electricpole,
                      html: '🖈',
                    }),
                    title: 'Place electric pole marker'
                },                                                                      

            ];
        }
    });

my code show variable electricpole should change icon from into 🖈.. but i try did not work... can somebody help me how to change it.

来源:https://stackoverflow.com/questions/44381913/change-default-icon-toolbar-leaflet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!