Fixed 2013-01-10: Thanks to Alexander Skaburskis: https://groups.google.com/forum/?fromgroups=#!topic/d3-js/lm3nmWyEXwk
I'm using polymaps and D3 to overlay a large geoJSON object (created from a shapefile) on a map. d3 is doing the overlay, not polymaps.
Normally, the paths of the overlayed regions would be re-loaded and projected on each move and zoom - i.e. update the path generator and the projection and re-generate each path on move. Since this is a very large set of objects, this takes a while.
To get nice and fluid updates on move and zoom, I thought I would do the following - on move/zoom, the whole group of region paths are not reloaded, rather they are scaled and translated along the x and y axes as necessary.
I've got the translation part down. I use findMapBounds() to get the coordinates of the upper left point of the group of paths, and translate by the difference with respect to the coordinates on initial load. it works fine.
However on zoom, it's not so easy. Getting the right factor by which to scale the group of paths is fine: I just calculate the ratio of the current path group bounds size to the initial size. The problem is that I also need to compensate for the translation when the map is zoomed. When the scale changes, I don't know how to translate to get the overlayed paths into the right spot.
Does anyone have an idea how to translate an object after a zoom? It seems like with that fixed, this method could prevent a lot of unnecessary path regeneration.
[note: small subset of data used in example dataset uk_lads.json]