【问题标题】:Hover tooltip on shapefile in Mapbox/TileMill在 Mapbox/TileMill 中的 shapefile 上悬停工具提示
【发布时间】:2013-12-08 02:57:56
【问题描述】:

我正在 TileMill 中创建一张地图,它按颜色显示各种建筑物的年龄。我有 4 个数据层(每个都有 50 年的建筑施工历史,因此可以打开/关闭)和一个基础层。

在 TileMill 中,当我将鼠标悬停在 shapefile 上时,我可以看到工具提示。我已经对它们进行了自定义,因此它显示了光标悬停在建筑物的建造年代。但是,当我导出到 MBTiles 以上传到 MapBox 以在我的网站上进行集成时,悬停功能消失了,并且没有图例。

我已经在 MapBox 的网站和 API 上搜索了几个小时以寻求帮助。我没有使用标记,所以我不能将其用作解决方案(有超过 800,000 座建筑物)。有没有办法做到这一点?

var map = L.mapbox.map('map', 'jacobs74.xoonovka', {
    legendControl: {
        // any of the valid control positions:
        // http://leafletjs.com/reference.html#control-positions
        position: 'bottomleft'
    }, zoomControl: false
})
    .setView([41.8928, -87.6491], 14),
    markerLayer = L.mapbox.markerLayer().addTo(map);
    map.gridControl.options.follow = true;
    new L.Control.Zoom({ position: 'topright' }).addTo(map);

        var gridLayer = L.mapbox.gridLayer('jacobs74.xoonovka');
    map.addLayer(gridLayer);
    map.addControl(L.mapbox.gridControl(gridLayer, {follow: true}));

L.control.layers({

     }, {
        'Thru 1899': L.mapbox.tileLayer('jacobs74.s37bpdgq'),
        '1900-1949': L.mapbox.tileLayer('jacobs74.fi084ush'),
        '1950-1999': L.mapbox.tileLayer('jacobs74.yh8prbfi'),
        '2000-Now': L.mapbox.tileLayer('jacobs74.awsw2ji1')
    }).addTo(map);

【问题讨论】:

    标签: javascript gis mapbox tilemill


    【解决方案1】:

    有点不清楚您的问题出在哪里。请附上您的代码副本。至于为图块和标记层创建工具提示。只需将 follow 选项设置为 true map.gridControl

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>Movetip</title>
    
      <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
      <script src='//api.tiles.mapbox.com/mapbox.js/v1.5.2/mapbox.js'></script>
      <link href='//api.tiles.mapbox.com/mapbox.js/v1.5.2/mapbox.css' rel='stylesheet' />
    
      <style>
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }
      </style>
    </head>
    <body>
    <div id='map'></div>
    <script>
    var map = L.mapbox.map('map', 'examples.map-8ced9urs');
    map.gridControl.options.follow = true;
    </script>
    </body>
    </html>
    

    【讨论】:

    • 我通过 JavaScript API 调用它。
    • 谢谢。能否请您附上您的代码的 sn-p 或 a gist
    • 是的,我编辑了原始问题以包含 sn-p。即使使用 map.gridControl.options.follow = true;它不会起作用。我很茫然。
    • 非常感谢。哪些图层有工具提示?有几种方法可以从 TileMill 导出图层,包括directly uploading them to mapbox.com。我在 tileJSON 层中看不到任何工具提示数据,在 the hosted maps. 上也看不到
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    • 1970-01-01
    • 2014-03-29
    • 2017-01-30
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多