-
Notifications
You must be signed in to change notification settings - Fork 227
gka edited this page Feb 2, 2012
·
11 revisions
map = new kartograph.Kartograph('#container');
map.loadMap('map.svg', function(map) {
// do something
});
The first thing you want to do after the map has been loaded is to set up your layer configuration. Kartograph SVG maps can store multiple map layers.
map.addLayer({
id: "countries"
})
You can specify a key attribute which will be used to identify the polygons in other API functions.
map.addLayer({
id: "countries",
key: "iso3"
})
Per default, the layer polygons will get the layer id as CSS class name. If you want to set up a different class name (for instance if you need to add a layer multiple times), you can do so via className attribute:
map.addLayer({
id: "countries",
className: "mycountries"
})
map.addLayer({
id: "countries",
className: "usa",
filter: function(d) {
return d.iso3 == "USA"
}
})
new Kartograph.SymbolGroup({
map: map,
data: mydata,
type: "Bubble",
radius: function(d) { return Math.sqrt(d.value) }
});
In choropleth maps, each map region will be colored according to some data value.
map.choropleth({
data: mydata,
colors: function(d) {
return '#f94'; // return color based on data value/object
}
});