css - Scalable canvas as overlay in Google Maps Javascript API -
i have image (9600x7200) using overlay on google maps enabled web page. anchor sw , nw corners latlng , image scales correctly when zoom map. want create second overlay html5 canvas element, sized 9600x7200, sits on top of image. can when draw on canvas, scaling/positioning wrong. used https://developers.google.com/maps/documentation/javascript/examples/overlay-simple template both overlays, sets overlay element 100% of parent div, anchored map. works fine <img>
, not html5 canvas, not have inherent size image does. (you can set width/height in css, underlying image has real dimensions scale css dimensions).
so, question is: how create drawable canvas size of 9600x7200, , anchor map positions , scales match <img>
overlay beneath it? there code samples this?
don't use css resize canvas, set via width , height attributes of canvas element. if draw on canvas (let's it's stretched twice it's normal size simplicity) both it's size , position stretched well. if try change color of pixel @ x: 10, y: 10, you'll 2x2 (approximately) square @ x: 20, y: 20.
Comments
Post a Comment