传单-添加图例标题 [英] leaflet - Adding a legend title

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

问题描述

我是Leaflet的新手,目前正在努力学习教程.到目前为止,我设法创建了一个交互式的螺旋形地图,如示例 http://leafletjs.com/examples/choropleth.html .

I am new to Leaflet and I am currently struggling with tutorials. So far I managed to create an interactive clorophet map, like in the example http://leafletjs.com/examples/choropleth.html.

我有一个问题:是否可以为页面右下角的有标题添加标题(简单文本,不是动态文本)?有人可以通过仅参考链接的示例来告诉我如何做吗?

I have a question: is it possible to add a title (simple text, not dynamic) to the legged located on the bottomright of the page? Could anyone tell me how, by just referring to the linked example?

非常感谢, G.

推荐答案

您只需要在"THE TITLE"下添加标题即可.

You just need to add your title under "THE TITLE"...

var legend = L.control({position: 'topleft'});  
    legend.onAdd = function (map) {

    var div = L.DomUtil.create('div', 'info legend'),
        grades = [50, 100, 150, 200, 250, 300],
        labels = ['<strong> THE TITLE </strong>'],
        from, to;

    for (var i = 0; i < grades.length; i++) {
        from = grades [i];
        to = grades[i+1]-1;

    labels.push(
        '<i style="background:' + getColor(from + 1) + '"></i> ' +
        from + (to ? '&ndash;' + to : '+'));
        }
        div.innerHTML = labels.join('<br>');
        return div;


        };

这篇关于传单-添加图例标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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