mapbox / mbutil

Importer and Exporter of MBTiles
http://mapbox.com/developers/
BSD 3-Clause "New" or "Revised" License
755 stars 198 forks source link

Using interactivity layer #23

Closed gavriguy closed 12 years ago

gavriguy commented 12 years ago

Regarding to issue https://github.com/mapbox/mbutil/issues/7 Can someone please explain how do i use the grid.json files i got after exporting on Wax? I'm trying to create a Wax modest map with static tiles I made using mbutil. Seeing that the code exports also the json info i'm wandring how can I use it to add an interaction layer that i created using tilemill.

<html>
  <head>
    <script src='ext/modestmaps.min.js' type='text/javascript'></script>
    <script src='dist/wax.mm.js' type='text/javascript'></script>
    <link href='theme/controls.css' rel='stylesheet' type='text/css' />
    </head>
    <body>
        <div id="modestmaps-setup"></div>
        <script>
        var tilejson = {
          tilejson: '1.0.0',
          scheme: 'tms',
          tiles: ['t1/1.0.0/t1/{z}/{x}/{y}.png'],
            grids: ['t1/1.0.0/t1/{z}/{x}/{y}.grid.json']
        };
        var mm = com.modestmaps;
        var m = new mm.Map('modestmaps-setup',
          new wax.mm.connector(tilejson),           
          new mm.Point(240,240));
         //Adding interaction doesn't seem to work. any ideas?
            wax.mm.interaction(m, tilejson);
        m.setCenterZoom(new mm.Location(39, -98), 2);
        </script>

    </body>
</html>
tmcw commented 12 years ago

mb-util exports a metadata.json file - use the formatter key from that in your tilejson definition.

gavriguy commented 12 years ago

Thanks it works :)