GEO

by geolocationmarker on February 18th, 2012
No notes
Syntax: JavaScript
Show lines - Hide lines - Show in textbox - Download
  1. <html>
  2. <head>
  3. <title>Marcadores en google Maps</title>
  4. <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
  5. <meta http-equiv="content-type" content="text/html" charset="utf-8">
  6. <style type="text/css">
  7. html, body {
  8. margin: 0px;
  9. padding: 0px;
  10. }
  11. #geomap {
  12. padding:0px;
  13. margin:0px;
  14. }
  15. @media all {
  16. #geomap {width:90%; height:90%;}
  17. }
  18. @media (max-width: 980) and (min-width:768px) {
  19. #geomap {width: 980px; height:100%;}
  20. }
  21. @media (min-width: 481px) and (max-width: 768px) {
  22. #geomap {width: 768px; height:100%;}
  23. }
  24. @media (min-width: 321px) and (max-width: 480px) {
  25. #geomap {width: 480px; height:100%;}
  26. }
  27. @media (max-width: 320px) {
  28. #geomap {width:320px; height:100%;}
  29. }
  30. </style>
  31. <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false">
  32. </script>
  33. <script>
  34. function initialize(){
  35. function posicion(p){
  36. latitude = p.coords.latitude;
  37. longitude = p.coords.longitude;
  38. alert('Lont/Latitud actual:' + latitude + ' ' + longitude);
  39.  
  40. //creamos el mapa
  41. var myLatlng = new google.maps.LatLng(latitude,longitude);
  42. var myOptions = {
  43. zoom: 20,
  44. center:myLatlng,
  45. mapTypeId:google.maps.MapTypeId.ROADMAP
  46. }
  47. var map = new google.maps.Map(document.getElementById("geoMap"),myOptions);
  48. var marker = new google.maps.Marker({
  49. position:myLatlng,
  50. map:map,
  51. title: "Estoy en KMMX"
  52. });
  53.  
  54. }
  55. function manejaerror(errorposicion){
  56. alert('El intento por obtener la ubicacion fallo' + errorposicion.message);
  57. }
  58. navigator.geolocation.getCurrentPosition(posicion,manejaerror);
  59.  
  60. }
  61.  
  62. </script>
  63.  
  64. </head>
  65. <body onload="initialize()">
  66. <div id="geoMap"></div>
  67. </body>
  68. </html>

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS