单张自定义控件位置:居中 [英] Leaflet Custom Control position: center

查看:63
本文介绍了单张自定义控件位置:居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在连接一个眼动仪来控制传单地图(平移,缩放等).我们希望有一个自定义控件出现在地图中心(用于菜单功能).目前,传单不支持位置:居中")(支持左上角等)的想法?

we are hooking up an eye-tracker to control the leaflet map (pan, zoom etc.) We would like to have a custom control that appears at the center of the map (for menu functions) Currently Leaflet does not support position: 'center') (topleft, etc. is supported) ideas?

推荐答案

在传单上的地图上添加自定义控件就是这样.

Adding a custom control on a map on leaflet is performed like that .

例如徽标:

var logo= L.control({
    position : 'topleft'
});
logo.onAdd = function(map) {
    this._div = L.DomUtil.create('div', 'myControl');
    var img_log = "<div class="myClass"><img src=\"images/logo.png\"></img></div>";

    this._div.innerHTML = img_log;
    return this._div;

}
logo.addTo(map);

然后,您可以将CSS样式添加到myClass中以使其居中:(该部分尚未经过我的测试)

Then, you can add CSS style to myClass to center it: (this part has not been tested by myself)

.myClass {
   padding-top:50%;
   padding-left: 50%;
}

这篇关于单张自定义控件位置:居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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