Commits on Aug 10, 2010
  1. Ignore invalid latitudes in hash control.

    If the latitude specified was -90 or less, or +90 or greater, the center of the
    map could become invalid (NaN), causing the map to crash. Now we clamp the
    latitude to the range [-89.99999999, 89.99999999].
    mbostock committed Aug 10, 2010
Commits on Aug 9, 2010
  1. Fixes for non-root maps.

    If the map's container is not a root SVGSSVGElement, then we need to apply the
    inverse transform to convert the mouse location to view coordinates. Also, set
    the size of the child rect to be the actual size of the map, rather than 100% of
    the window width and height.
    mbostock committed Aug 9, 2010
  2. Use `zoomBy` to set zoom and center simultaneously.

    Previously, the hash control would call `zoom` then `center`, which would
    trigger two move events. By using `zoomBy`, we coalesce these two steps into one
    move event, avoiding spurious tile loads. This is also important if, say, a
    listener sets the allowable zoom range based on the map center.
    mbostock committed Aug 9, 2010
Commits on Aug 8, 2010
  1. Fix a crash when emptying the cache.

    There was a bug in fixing the doubly-linked list when the last entry was removed
    from the cache. Thanks to Aaron Straup Cope for finding the bug!
    mbostock committed Aug 8, 2010
Commits on Aug 6, 2010
  1. Make polymaps.min.js target writeable.

    I'm leaving polymaps.js read-only, so that I don't accidentally edit polymaps.js
    when debugging. But when copying polymaps.min.js to another directory, it's
    useful for the file to be writeable so that I don't have to cp -f.
    mbostock committed Aug 6, 2010
  2. Fix two bugs with proxy tiles.

    With zoom transforms, it was possible for a proxy tile to be less than -4 or
    greater than +2 zoom levels from the map zoom level. This caused Polymaps to
    crash because the corresponding layer `g` element was missing. Now we properly
    shift the proxy zoom levels when a zoom transform is used.
    Another problem with proxy tiles is that we were accidentally doubling the proxy
    count for tiles along the viewport diagonal, per the new scanline algorithm. We
    now compute the correct proxy count, which is necessary so that the proxy tiles
    are removed when the referenced tiles load.
    mbostock committed Aug 5, 2010
Commits on Aug 5, 2010
  1. Layer transforms!

    Layers can now have associated affine transforms, affecting the layer's local
    tile coordinates. For example, this allows an individual layer to be rotated,
    scaled and translated within the map.
    mbostock committed Aug 5, 2010
Commits on Aug 4, 2010
  1. Use scanline algorithm to determine visible tiles.

    Previously, if the map were rotated, we would compute the axis-aligned bounding
    box to determine which tiles were visible. This is easy, but has the undesirable
    property that it can load (and display) many tiles that are inside the bounding
    box but outside the viewport.
    Now we use the triangle scanline algorithm to determine exactly which tiles are
    visible. The algorithm is modified slightly so that it displays any pixel (i.e.,
    tile) that intersects the triangle.
    mbostock committed Aug 4, 2010
Commits on Aug 3, 2010
  1. Improve stability of mousewheel interaction (again).

    The previous fix suffered from two problems.
    First, redundant hashchange events are occasionally dispatched by the browser,
    and later events would not be ignored; thus the hash control would end up moving
    the map on map move. We avoid this now by caching the location hash, and only
    moving the map when the hash changes. This also allows us to ignore the
    hashchange event when the map moves.
    Second, the wheel control was caching the location under the mouse, and only
    updating it when the mouse moves. However, the map can move independently of the
    mouse, for example with arrow controls or animation. Thus, we now clear the
    cached location when the map moves. (And, we're careful to preserve the cached
    location when we zoom the map.)
    mbostock committed Aug 3, 2010
  2. Simplify overlay example using Layer.

    We implement the static image overlay using a custom (but simple!) layer
    implementation that creates an image tile.
    mbostock committed Aug 3, 2010
  3. Improve stability of mousewheel interaction.

    Previously, the location under the mouse could drift as the mousewheel was used
    to zoom in and out. Now we compute the location under the mouse on mousemove, so
    that it does not drift when the map is zoomed. The location is specified as an
    optional third argument to `map.zoomBy`.
    The `map.panBy` method is reimplemented to be slightly faster and more accurate
    by avoiding an extra point <-> location conversion.
    Most importantly, the hash control now ignores the 'hashchange' event that it
    generates when it changes the hash. Previously, this was causing noticeable
    aliasing on smooth zoom as any movement of the map would be rounded to the
    precision of the hash control.
    mbostock committed Aug 3, 2010
Commits on Aug 2, 2010
  1. Rotation!

    Maps can now be rotated using the `angle` property. For simplicity, the layer
    implementation currently computes the bounding box to fill the rotated viewport;
    in a future commit we will use a scanline fill algorithm to avoid loading tiles
    outside the viewport.
    This commit also fixes a bug in the `coordinatePoint` and `pointCoordinate`
    methods, which were treating points pre-fractional zoom. Now points are always
    considered to be in screen space (pixel coordinates), consistent with the
    `locationPoint` and `pointLocation` methods. Note, however, that the
    tile-specific projection used by layers is still pre-transform.
    mbostock committed Aug 2, 2010
Commits on Jul 28, 2010
  1. New layer `visible` property.

    A layer's visibility can now be toggled without adding or removing the layer
    from the map. This avoids inadvertantly changing the z-order of layers. In
    addition to removing the tiles from the SVG image, the layer container's
    visibility attribute is set to "hidden", such that if the user has extended the
    layer with additional elements, they become hidden as well.
    mbostock committed Jul 28, 2010
Commits on Jul 27, 2010
  1. Refine the tile scale & rounding logic.

    We now apply the scale transform to the layer group elements, rather than to
    each tile individually. In addition, rather than rounding each tile's position,
    we round the tileCenter coordinate.
    mbostock committed Jul 27, 2010
  2. Fix zoom transforms with non-tiled layers.

    Previously, if a zoom transform was used with a non-tiled layer, it could cause
    no tiles to be displayed. Now we guarantee that at least one (world-size) tile
    is visible.
    mbostock committed Jul 27, 2010
  3. Improve performance of re-adding a layer.

    Previously, when re-adding a layer to its map, the layer would be removed from
    the map only to be immediately added back. This prevents the browser from
    efficiently updating the display. Now we do the minimal amount of work, while
    still guaranteeing that layers appear in the order they were added.
    mbostock committed Jul 27, 2010
  4. Fix a bug in event dispatch.

    If an event listener is removed during an event dispatch, it shouldn't receive
    the active event. So now in addition to storing a defensive copy, we use a
    wrapper object for the event handler to store an `on` boolean. This is set to
    false when the listener is removed, preventing that handler from receiving the current event.
    mbostock committed Jul 27, 2010
  5. Make a defensive copy of registered listeners.

    This way, if a listener is removed while events are being dispatched, we won't
    inadvertantly skip a listener.
    mbostock committed Jul 27, 2010
  6. Cache reference to map.

    This way, if the layer is removed from the map by the time loaded tiles arrive,
    the map is still available for the purposes of projection.
    mbostock committed Jul 27, 2010
Commits on Jul 25, 2010
  1. Added Stamen to copyright

    Michal Migurski committed Jul 25, 2010
  2. Fixing the "logo" :)

    RandomEtc committed Jul 25, 2010
Commits on Jul 23, 2010
  1. Listen for hashchange events.

    Now, when the location.hash changes, the map center and zoom will change
    accordingly. This is particularly nice for pasting in a URL that only differs by
    hash. Also, the hash control now ignores the hash if any part of it isNaN, or if
    it contains fewer than three components.
    mbostock committed Jul 23, 2010
Commits on Jul 18, 2010
  1. Switch CloudMade API key.

    Please get your own API key at!
    mbostock committed Jul 18, 2010
  2. Ignore empty GeoJSON features.

    mbostock committed Jul 18, 2010
  3. Don't callback for empty responses.

    JSON.parse("") fails.
    mbostock committed Jul 18, 2010