L.Control
所有leaflet控制的基础类。继承自IControl接口。 你可以这样添加控件:
control.addTo(map);
// the same as
map.addControl(control);
构造器
L.Control( <Control options> options? ) |
new L.Control(…) L.control(…)
|
通过给定的选项创建一个控制。 |
Options
position |
String |
'topright' |
控制初始的位置(在地图的某一角)。参见 control positions. |
Methods
setPosition( <String> position ) |
this |
设置控制的位置。参见 control positions. |
getPosition() |
String |
返回控制的当前位置。 |
addTo( <Map> map ) |
this |
将控制添加到地图上。 |
removeFrom( <Map> map ) |
this |
将控制从地图上移除。 |
getContainer() |
HTMLElement |
返回 the HTML container of the control. |
Control Positions(控制的位置)
Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.
'topleft' |
地图的左上角。 |
'topright' |
地图的右上角。 |
'bottomleft' |
地图的左下角。 |
'bottomright' |
地图的右下角。 |
下面讲下如何创建一个自定义控件
基本模板:
L.Control.XXX= L.Control.extend({ //在此定义参数
options: { },
//在此初始化 initialize: function (options) { L.Util.extend(this.options, options); }, onAdd: function (map) { //可在此添加控件内容 } });
以此模板创建一个简单图例控件
L.Control.Legend = L.Control.extend({ options: { position: 'topright' //初始位置 }, initialize: function (options) { L.Util.extend(this.options, options); }, onAdd: function (map) {
//创建一个class为leaflet-control-clegend的div
this._container = L.DomUtil.create('div', 'leaflet-control-clegend');
//创建一个图片要素 var legendimg = document.createElement('img'); legendimg.id = 'leaflet-control-clegend'; legendimg.type = 'img'; legendimg.src = "../../Content/legend.png"; this._legendimg = legendimg; //创建一个关闭控件的按钮 var closebutton = document.createElement('a'); closebutton.id = 'leaflet-control-geosearch-close'; closebutton.className = 'glyphicon glyphicon-remove'; this._closebutton = closebutton; this._container.appendChild(this._closebutton); this._container.appendChild(this._legendimg); //注册关闭事件 L.DomEvent.addListener(this._closebutton, 'click', this._onCloseControl, this); return this._container; }, _onCloseControl: function () { this._map.options.Legend = false; this.removeFrom(this._map); }, });
在定义一些样式后效果如下
高级一点可以定义如下扁平样式的:
相关推荐
12.如何使ListControl控件支持整栏选择?(Visual C++编程 源代码)12.如何使ListControl控件支持整栏选择?(Visual C++编程 源代码)12.如何使ListControl控件支持整栏选择?(Visual C++编程 源代码)12.如何使...
使用Custom Control自定义控件 使用Custom Control自定义控件 使用Custom Control自定义控件
BeamNG.drive Remote Control Remote Control app for the PC game BeamNG.drive. Communication functionality App sends out a broadcast in its local wifi on port 4444. It sends the string "beamng" ...
Automatic Control Systems
J.E. Marsden.Geometric Control of Simple Mechanical Systems.Springer.2004, good
ControlCAN ControlCAN_x64.zip ControlCAN.h x64 ControlCAN.dll ControlCAN.lib ControlCAN_x32.zip ControlCAN.h x32 ControlCAN.dll ControlCAN.lib 接口函数库(二次开发库)使用说明书.pdf
L.Control.Zoomslider.css
Halcon,对 HWindowControl 二次开发,封装,实现图像的缩放 平移;源代码实现。
C# WPF custom control自定义控件的设计与应用 1. 基于control的自定义控件的cs及xaml文件设计 2.自定义控件的应用
DameWare破解版 内网管理利器 内网渗透必备
Wrox.Professional.ASP.NET.2.0.Server.Control.and.Component.Development.Aug.2006.eBook(内容全面,深入,对服务器控件进行全面剖析)
通过Script Control从一个Form调用另外一个Form中的过程
大屏液晶拼接控制软 Windows版本,RJ45串口操作 SP系列等通用 通过拖拉,点击可以控制矩阵切换信号等操作
CD Player...with volume control and a combo box for easier track selection.
wrox.professional.asp.net.2.0.server.control.and.component.development.aug.2006.图灵出版社的书籍。对你有帮图灵出版社的书籍。对你有帮助。
Windows.Media.MediaControl
Starting.Out.with.C++.from.Control.Structures.to.Objects.8th.Edition
led显示屏安装文件,用于公司LED欢迎牌模式修改与应用
Optimal Control Theory - An Introduction.(Kirk D. Dover, 2004
RJS.Web.WebControl.PopCalendar.dll下载,用于网页asp 时间选取周别