We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

webDesign on 07/12/06


Tagged

javascript google maps


Versions (?)


Who likes this?

18 people have marked this snippet as a favorite

luman
xaviaracil
alvaroisorna
aurele
px
nutella
powerkan
maese
ogee
pedro
vali29
visuallyspun
gAmUssA
buscarini
jeradhill
NooM
oriolfb
hans


Google Maps básico / Basic Google Map


Published in: JavaScript 


  1. ***** JAVASCRIPT EN EL HEAD *****
  2. // Conseguir la clave para el mapa en http://www.google.com/apis/maps/
  3. <script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=AQUI VA LA CLAVE"></script>
  4.  
  5. <script type="text/javascript">
  6. //<![CDATA[
  7. window.onload = mapasGoogle;
  8. window.onunload= GUnload;
  9.  
  10. function mapasGoogle() {
  11. if (GBrowserIsCompatible()) {
  12. var map = new GMap2(document.getElementById("mapaGoogle"));
  13. map.setCenter(new GLatLng(42.8475, -2.6820), 15); //Defino las coordenadas y nivel de zoom
  14. map.setMapType(G_HYBRID_TYPE); //Defino el tipo de mapa: hibrido
  15. map.addControl(new GSmallMapControl()); //Activo controles de movimiento y zoom del mapa
  16. map.addControl(new GMapTypeControl()); //Activo controles de tipo de mapa
  17. map.openInfoWindowHtml(map.getCenter(),
  18. ("<img src='images/logo.png' width='20' height='20' style='float:left; margin-right:10px' alt='' /><em>Titulo</em> <br /> Lorem ipsum dolor sit amet"));
  19. }
  20. }
  21. //]]>
  22. </script>
  23.  
  24. ***** HTML *****
  25. <div id="mapaGoogle" style="width:500px; height:400px"></div>

Report this snippet 

You need to login to post a comment.