将工具提示悬停在Mapbox/TileMill中的形状文件上

Hover tooltip on shapefile in Mapbox/TileMill

本文关键字:文件 TileMill 悬停 工具提示 Mapbox      更新时间:2024-05-05

我正在TileMill中创建一张地图,用颜色显示各种建筑的年代。我有4个数据层(每个数据层都有50年的建筑施工经验,所以它可以打开/关闭)和一个基本层。

在TileMill中,当我将鼠标悬停在形状文件上时,我可以看到工具提示。我已经对它们进行了定制,这样它就可以显示光标悬停的建筑的建造年代。然而,当我导出到MBTiles并上传到MapBox以在我的网站上进行集成时,悬停功能消失了,也没有传说。

我在MapBox的网站和API上搜索了几个小时寻求帮助。我没有使用Markers,所以我不能将其用作解决方案(有80多万栋建筑)。有办法做到这一点吗?

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);

问题出在哪里有点不清楚。请附上您的代码副本。至于为平铺层和标记层创建工具提示。只需将follow选项设置为真正的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>