Git Product home page Git Product logo

d3-geo-zoom's Introduction

d3.geoZoom

NPM package Build Size NPM Downloads

Apply zoom and pan user interactions to D3 spherical map projections in the same fashion as d3-zoom for regular cartesian coordinates. Generally used with Azimuthal projections, but also works for other projection types as long as scaling and rotation is supported.

Heavily based in previous work by Jason Davies' Rotate the World and Mike Bostock's Versor Dragging. Makes use of Fil's versors package for translating mouse coordinates to the sphere.

See the included examples (canvas and svg).

Quick start

import d3GeoZoom from 'd3-geo-zoom';

or

d3.geoZoom = require('d3-geo-zoom');

or even

<script src="//unpkg.com/d3-geo-zoom"></script>

then

d3.geoZoom()
    .projection(<mapProjection>)
    .onMove(<callbackFn>)
    (<mapDomNode>);

API reference

Method Description Default
projection([object]) Getter/setter for the D3 projection object whose position settings are modified according to the zoom/pan user interactions. The projection should support the scale and rotate methods. -
northUp([boolean]) Getter/setter for whether to maintain a north pointing upwards orientation or allow free rotation in all directions. false
scaleExtent([array]) Getter/setter for the scale extent ([min, max]) to restrict the zoom interaction to. [0.1, 1000]
onMove([fn({ scale, rotation })]) Callback function for when the projection object is updated due to a user interaction. This is a convenient place to bind the render function that redraws the map component elements according to the current projection settings. The callback function includes a single object parameter that contains the new scale and rotation values. -

d3-geo-zoom's People

Contributors

antonytrupe avatar fil avatar melalj avatar vasturiano avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.