I have a map image on canvas that I would like to use as a Google map interface using HTML5 and jQuery. I would like to do the following:
• Double click on pan in without changing the size of the containing div • Click on a building to bring up a pop up of information on that building • Click and drag to pan
The code I have now is an image in a canvas. I found several codes that show “scaling” in the image, but either resize the div container, or are not a smooth and responsive way to execute it, it just jumps to a larger size, and I would like the scaling to be animated.
There will be several buildings on the map that are “pinned” on the map, which the user can click to open information about this building.
The code is as follows:
JS:
$( document ).ready( function() { var canvas = document.getElementById( 'canvas' ); var context = null; var map = null; if( canvas.getContext ) { context = canvas.getContext( '2d' ); $( '#map' ).load( function( evt ) { context.drawImage( evt.currentTarget, 10, 10 ); } ); map = new Image(); map.onload = function() { context.drawImage( this, 20, 20 ); }; map.src = 'images/asu_poly_map.png'; } else { alert( 'Your browser does not support canvas.' ); } } );
HTML:
<div id="map"> <canvas id="canvas" width="1055" height="600"></canvas> </div>
CSS
#map { margin:0 auto; margin-top : 180px; width : 1200px; }
EDIT: I assume that it will be something similar to this, but cannot figure out how to apply it to the image from the server drawn on the canvas.
Zoom in (using scale and translation)
source share