HTML5 Canvas Map Clickaround Primer Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

HTML5 Canvas Map Clickaround Primer Tutorial

HTML5 Canvas Map Clickaround Primer Tutorial

HTML5 brought in the incredibly useful โ€œcanvasโ€ element, for the first time. Its existence opens up a whole new world of possibilities for web applications that are graphical by nature.

With the canvas elementโ€™s drawImage() method you can draw more than your own geometrical constructs, you can have an image, and that image could be a map, as for todayโ€™s โ€œIreland Clickaroundโ€ web application (with access to maps of Brazil and United States of America and the World too), where you click on the map (and thanks to mapsofworld.com for downloadable free maps here) to show a Google Map of interest via Google Chart Map Chart. Maybe you can use the map of Ireland to โ€ฆ

  • plan a trip
  • look up where relatives live
  • imagine youโ€™re in Oโ€™Connell Street

This web application calls on tiny bits of mapping knowledge, namely the โ€œorientationโ€ of your โ€œmapโ€, as you are effectively digitizing to show where you want your Google Map to zoom in on.

This is one of those occasions that your (simple) software is a lot more effective using the Mercator map projection (that exaggerates the polar areas (like you might have had at school) because the simple latitude and longitude distances everywhere are the same (but relative areas definitely are not (ie. much bigger than reality near the poles))). Unfortunately, our United States of America projection is not Mercator, but youโ€™ll still get a โ€œball parkโ€ Google Maps feel.

So we can have it that if the user doesnโ€™t zoom, they need no orientation checks, but otherwise we need to determine a scale, by the user clicking on Dublin, on the map, and from that, we can work out the scaling that needs to be applied, as the top left co-ordinate is arranged to be (0,0) via the style=โ€position: absolute; top:0; left:0; โ€œ part of โ€ฆ



<canvas id="canvaselement" width=600 height=600 style="position: absolute; top:0; left:0; " />

Please have a go of our liveโœ‚run or download the HTML programming source code you could call irelandโšซhtml (brazilโšซhtml, united_statesโšซhtml, worldโšซhtml), or do both?!

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, GUI, Land Surveying, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

27 Responses to HTML5 Canvas Map Clickaround Primer Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *