cmanon / kartograph.js

Open source JavaScript renderer for Kartograph SVG maps

Home Page:http://kartograph.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kartograph.js

Kartograph.js is a JavaScript library that renders SVG maps in web browsers. It is built on top of jQuery and RaphaelJS. Please have a look at the API docs for more details.

Initializing a new map

map = $K.map('#map', 600, 400);
map.loadMap('world.svg', function() {
	map.addLayer({
		id: 'countries',
		key: 'iso3',
		title: function(d) { return d.countryName; }
	});
});
```

Choropleth maps (aka coloring map polygons based on data):

```javascript
pop_density = { 'USA': 123455, 'CAN': 232323, ... };

colorscale = new chroma.ColorScale({
	colors: chroma.brewer.YlOrRd,
	limits: chroma.limits(pop_density, 'k-means', 9)
});

map.choropleth({
	data: pop_density,
	color: function(value) {
		return colorscale.getColor(value);
	}
});
```

Adding symbols is easy, too:

```javascript
cities = [{ lat: 43, lon: -75, label: 'New York', population: 19465197 }];

new $K.SymbolGroup({
	map: map,
	data: cities,
	location: function(d) { return [d.lon, d.lat]; },
	type: 'Bubble',
	radius: function(d) { return Math.sqrt(d.population) * 0.001; }
})
```

### Author

Kartograph was created by [Gregor Aisch](http://github.com/gka/). It is supported by [Piwik Web Analytics](http://piwik.org) and the [Open Knowledge Foundation](http://okfn.org). 

### License

Kartograph.js is licensed under [GPL](http://www.gnu.org/licenses/gpl-3.0.txt)



About

Open source JavaScript renderer for Kartograph SVG maps

http://kartograph.org


Languages

Language:JavaScript 60.2%Language:CoffeeScript 39.6%Language:Shell 0.2%