Code Monkey home page Code Monkey logo

leaflet.d3's Introduction

D3.Leaflet

takes geojson or topojson and uses d3 (possibly with the help of topojson) to add it to a leaflet map as a layer. Bassed off this example

not sure if it actually solves any problem besides helping me learn d3.

api:

L.d3(data,options);
//or
new L.D3(data,options);

where data is either a url to geojson or topojson data or it can be an object, and options include:

  • "topojson" which is false if not topojson or the name of the topojson object you want.
  • "pathClass" the class your paths should have, this defaults to "path" and can be a string or a function which recieves the feature and returns the path string.
  • "type" whether d3 should download and treat it as json, csv, xml, text, tsv, html. Considering how this library makes some pretty strong assumes re it being json I'd not touch this. Forget I put this here.

Your going to want to add css styles manually, note that by default csv closes paths and fills them for you if you don't specify "fill:none;" Also I'd avoid styling "path" as that will effect all leaflet paths, including regular ones made inside leaflet.

the layer also has a method "bindPopup" with one argument which is content. This binds a popup to the layer with the content set to content, which may be a string which is just passed on unchanged or a function which is called on the properties of the feature clicked question.

added two more options, svgClass which just takes a string which lets you set a class on the whole layer, useful for things like colorbrewer which expect this, and "before" which takes a function and is called with the data as an argument and the feature class as this. useful if you need to calculate stats for a range. its called right before the feautes are added to the map and right after path and bounds are calculated.

leaflet.d3's People

Watchers

James Cloos avatar Fredrick Njenga 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.