Hover tooltip on shapefile in Mapbox/TileMill

1.1k views Asked by At

I'm creating a map in TileMill which shows the age of various buildings by color. I have 4 data layers (each with 50 years of building construction, so it can be toggled on/off) and a base layer.

Within TileMill I can see tooltips when I hover over the shapefiles. I've customized them so it shows the age of construction of the building the cursor is hovering over. However when I export to MBTiles to upload to MapBox for integration on my website, the hover functionality is gone, and there is no legend.

I have searched for hours for help on MapBox's website and API. I am not using Markers so I cannot use that as a solution (there are over 800,000 buildings). Is there any way to do this?

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

There are 1 answers

4
geraldarthur On

It's a bit unclear where your issue is. Please include a copy of your code. As for creating a tooltip for tile as well as marker layers. Just set the follow option to 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>