Created
October 17, 2011 23:40
Revisions
-
strongwave revised this gist
Oct 19, 2011 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,26 @@ <html> <head> <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> jQuery(window).ready(function(){ g_initialize(); jQuery("#findLocationBtn").click(initiate_geolocation); }); function g_initialize() { var google_tile = "http://maps.google.com/maps/api/staticmap?sensor=false¢er=-34.397,150.644&zoom=8&size=300x400" var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); var imageObj = new Image(); imageObj.src = google_tile; imageObj.onload = function(){ context.drawImage(imageObj, 0, 0); } } function initiate_geolocation() { navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors); } -
strongwave revised this gist
Oct 18, 2011 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,9 +48,7 @@ <div> <button id="findLocationBtn" >Draw My Location on Google Map</button> </div> <canvas id="myCanvas" width="300px" height="400px" style="border:1px solid grey;"> </canvas> </body> </html> -
strongwave revised this gist
Oct 18, 2011 . 2 changed files with 56 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,38 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script> jQuery(window).ready(function(){ jQuery("#findLocationBtn").click(initiate_geolocation); }); function initiate_geolocation() { navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors); } function handle_errors(error) { switch(error.code) { case error.PERMISSION_DENIED: alert("user did not share geolocation data"); break; case error.POSITION_UNAVAILABLE: alert("could not detect current position"); break; case error.TIMEOUT: alert("retrieving position timed out"); break; default: alert("unknown error"); break; } } function handle_geolocation_query(position) { var google_tile = "http://maps.google.com/maps/api/staticmap?sensor=false¢er=" + position.coords.latitude + "," + position.coords.longitude + "&zoom=14&size=300x400&markers=color:blue|label:U|" + position.coords.latitude + ',' + position.coords.longitude; var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); var imageObj = new Image(); imageObj.src = google_tile; imageObj.onload = function(){ context.drawImage(imageObj, 0, 0); } } </script> </head> <body> <div> <button id="findLocationBtn" >Draw My Location on Google Map</button> </div> <div> <canvas id="myCanvas" width="300px" height="400px" style="border:1px solid grey;"> </canvas> </div> </body> </html> -
strongwave created this gist
Oct 17, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <!DOCTYPE HTML> <html> <head> <script> function loadCanvas(dataURL){ var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // load image from data url var imageObj = new Image(); imageObj.onload = function(){ context.drawImage(this, 0, 0); }; imageObj.src = dataURL; } window.onload = function(){ // make ajax call to get image data url var request = new XMLHttpRequest(); request.open("GET", "http://maps.google.com/maps/api/staticmap?sensor=false¢er=37.354107,-121.955235&zoom=14&size=300x400&markers=color:blue|label:S|37.354107,-121.955235", true); request.onreadystatechange = function(){ if (request.readyState == 4) { // Makes sure the document is ready to parse. if (request.status == 200) { // Makes sure it's found the file. loadCanvas(request.responseText); } } }; request.send(null); }; </script> </head> <body onmousedown="return false;"> <canvas id="myCanvas" width="578" height="200" border: 1px solid #9C9898;> </canvas> </body> </html>