cutting-room-floor / wax

DEPRECATED: consult mapbox.js
https://github.com/mapbox/mapbox.js
BSD 3-Clause "New" or "Revised" License
167 stars 42 forks source link

tiles flickering using google maps connector with google maps 3.10 #274

Open javisantana opened 11 years ago

javisantana commented 11 years ago

the connector must be a MapType because the new google maps version wraps getTile method

tokumine commented 11 years ago

For any wandering souls out there, here is a workaround to get interactivity and non-flickering tiles in google maps when using wax:

 wax.tilejson('url_to_tilejson.json', function(tilejson) {

    var b = new wax.g.connector(tilejson);
    var c = new google.maps.ImageMapType(b);
    c.cache=b.cache;
    c.interactive=true;

    var old_getTile = c.getTile;
    c.getTile=function(p,zoom,doc) {
      var div=old_getTile.call(c,p,zoom,doc)
      var key=zoom + '/' + p.x + '/' + p.y;
      c.cache[key] = div;
      c.cache[key].src = b.getTileUrl(p, zoom);
      return div;
    }

    map.overlayMapTypes.insertAt(0, c);
    wax.g.interaction().map(map).tilejson(tilejson).on(wax.tooltip().parent(map.getDiv()).events());
    wax.g.interaction().map(map).tilejson(tilejson).on('on',function(o){console.log(o);});
  });