Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Created June 30, 2011 14:55
Show Gist options
  • Save wyattdanger/1056396 to your computer and use it in GitHub Desktop.
Save wyattdanger/1056396 to your computer and use it in GitHub Desktop.
playing with canvas to draw map
(function () {
// MC Namespace
var MC = {
Map: function () {},
Marker: function () {}
};
// MC Map
MC.Map.prototype = {
init: function () {
this.drawMap();
},
drawMap: function (id) {
var canvas = document.getElementById('map'),
ctx = canvas.getContext('2d'),
map = new Image();
canvas.setAttribute('width', 930);
canvas.setAttribute('height', 475);
map.onload = function(){
ctx.drawImage(map, 0, 0);
};
map.src = '/images/map.png';
}
};
// MC Marker
MC.Marker.prototype = {
init: function () {
console.log('initialized');
}
};
// jQuery DOMReady Initializer
$(function () {
var map = new MC.Map();
map.init();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment