function myClient() {
if (!(this instanceof arguments.callee)) {
return new arguments.callee(arguments);
}
var self = this;
this.init = function() {
self.viewDidResize();
self.drawSvg();
};
this.viewDidResize = function () {
var width = $('body').width(),
windowHeight = $(window).height(),
mapCanvasHeight = width * (369.0 / 567.0);
console.log(self.svg);
self.svg.setSize(width, mapCanvasHeight);
$('#map').css({
'margin-top': 10
});
}
this.drawSvg = function() {
var data;
var width = $('body').width();
// Most parts of D3 don"t know anything about SVG—only DOM.
self.svg = d3.select("#map").append("svg:svg")
//.attr("width", "100%").attr("height", "100%");
//better to keep the viewBox dimensions with variables
//.attr("viewBox", "0 0 " + width + " " + mapCanvasHeight );
.attr('viewBox', '0 0' + width + '369');
self.map = d3.geo.equirectangular();
self.projection = d3.geo.path().projection(self.map);
self.countries = self.svg.append("svg:g").attr("id", "countries");
// Load data from .json file
d3.json("../data/world-countries.json", function(json) {
var myClient;
jQuery(function() {
myClient = new myClient();
$(window).resize(function() {
console.log("window resized");
myClient.viewDidResize();
});
});
what is the correct way to make resize the map when the navigator window is resized. is there a way to set the size, like