Foros del Web » Programando para Internet » Jquery »

Efecto jquery con google maps

Estas en el tema de Efecto jquery con google maps en el foro de Jquery en Foros del Web. Hola a todos, Estoy haciendo pruebas con la api v3 de google map y me ha surgido un problema. Quiero mostrar un mapa de una ...
  #1 (permalink)  
Antiguo 23/11/2011, 12:09
 
Fecha de Ingreso: mayo-2010
Mensajes: 3
Antigüedad: 13 años, 11 meses
Puntos: 0
Efecto jquery con google maps

Hola a todos,

Estoy haciendo pruebas con la api v3 de google map y me ha surgido un problema.
Quiero mostrar un mapa de una determinada zona permitiendo que el usuario arrastre una marca, eso lo tengo conseguido pero por defecto quiero que aparezca la capa oculta. He estado mirando los efectos de jquery y quiero mostrarla de forma que se vaya mostrando lentamente generando un efecto. Bien pues todo eso esta bien pero cuando muestra el mapa, lo muestra de manera incorrecta, la mitad del mapa no me carga y carga una imagen gris.

La página de ejemplo es esta:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Informacion imagen</title>
  5. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  6. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
  7. <script type="text/javascript">
  8. function cambia(){
  9.     $("#mapCanvas").show(2000);
  10.   }
  11.  
  12.  
  13. var geocoder = new google.maps.Geocoder();
  14. var map;
  15.  
  16. function geocodePosition(pos) {
  17. geocoder.geocode({
  18. latLng: pos
  19. }, function(responses) {
  20. if (responses && responses.length > 0) {
  21. updateMarkerAddress(responses[0].formatted_address);
  22. } else {
  23. updateMarkerAddress('Cannot determine address at this location.');
  24. }
  25. });
  26. }
  27.  
  28. function updateMarkerStatus(str) {
  29. document.getElementById('markerStatus').innerHTML = str;
  30. }
  31.  
  32. function updateMarkerPosition(latLng) {
  33. document.getElementById('info').innerHTML = [
  34. latLng.lat().toFixed(3),
  35. latLng.lng().toFixed(3)
  36. ].join(', ');
  37. }
  38.  
  39. function updateMarkerAddress(str) {
  40. document.getElementById('address').innerHTML = str;
  41. }
  42.  
  43. function initialize() {
  44. $("#mapCanvas").hide();
  45. var myLatlng = new google.maps.LatLng(41.396, 2.144);
  46. var myOptions = {
  47. zoom: 11,
  48. center: myLatlng,
  49. mapTypeId: google.maps.MapTypeId.ROADMAP
  50. }
  51. map = new google.maps.Map(document.getElementById("mapCanvas"), myOptions);
  52.  
  53. var marker = new google.maps.Marker({
  54. position: myLatlng,
  55. draggable:true,
  56. map: map
  57. });
  58.  
  59. // Add dragging event listeners.
  60. google.maps.event.addListener(marker, 'dragstart', function() {
  61. //updateMarkerAddress('Dragging...');
  62. });
  63. google.maps.event.addListener(marker, 'drag', function() {
  64. //updateMarkerStatus('Dragging...');
  65. updateMarkerPosition(marker.getPosition());
  66. });
  67. google.maps.event.addListener(marker, 'dragend', function() {
  68. //updateMarkerStatus('Drag ended');
  69. geocodePosition(marker.getPosition());
  70. });
  71. }
  72.  
  73. function placeMarker(location) {
  74. var marker = new google.maps.Marker({
  75. position: location,
  76. draggable:true,
  77. map: map
  78. });
  79. // Update current position info.
  80. updateMarkerPosition(location);
  81. geocodePosition(location);
  82.  
  83. // Add dragging event listeners.
  84. google.maps.event.addListener(marker, 'dragstart', function() {
  85. //updateMarkerAddress('Dragging...');
  86. });
  87.  
  88. google.maps.event.addListener(marker, 'drag', function() {
  89. //updateMarkerStatus('Dragging...');
  90. updateMarkerPosition(marker.getPosition());
  91. });
  92.  
  93. google.maps.event.addListener(marker, 'dragend', function() {
  94. //updateMarkerStatus('Drag ended');
  95. geocodePosition(marker.getPosition());
  96. });
  97. }
  98.  
  99.  
  100.  
  101.  
  102. // Onload handler to fire off the app.
  103. <style type="text/css">
  104. body {
  105.     margin-left: 2px;
  106.     margin-top: 2px;
  107.     margin-right: 2px;
  108.     margin-bottom: 2px;
  109. }
  110. #mapCanvas {
  111. width: 500px;
  112. height: 400px;
  113. float: left;
  114. }
  115. .titulo {
  116.     font-family: Verdana, Geneva, sans-serif;
  117.     font-size: 14px;
  118.     font-style: normal;
  119.     font-weight: bold;
  120.     font-variant: normal;
  121.     color: #FFF;
  122. }
  123. #infoPanel {
  124. float: left;
  125. margin-left: 10px;
  126. }
  127. #infoPanel div {
  128. margin-bottom: 5px;
  129. }
  130. </head>
  131.  
  132. <body onload="initialize()">
  133. <table width="880" border="0" align="center" cellpadding="2" cellspacing="2">
  134.   <tr>
  135.     <td height="23" colspan="2" align="center" bgcolor="#757575" class="titulo">INFORMACIÓN DE LA IMAGEN</td>
  136.   </tr>
  137.   <tr>
  138.     <td width="356" height="420"><div id="infoPanel">
  139. <b>Marca:</b>
  140.  
  141. <div id="markerStatus"><i>Arrastra la marca.</i></div>
  142. <b>Posición actual:</b>
  143. <div id="info"></div>
  144. <b>Dirección:</b>
  145. <div id="address"></div>
  146. </div></td>
  147.     <td width="500" height="420" align="center" valign="top"><div id="mapCanvas"></div></td>
  148.   </tr>
  149.   <tr>
  150.     <td height="150" align="center" valign="middle"><img src="http://maps.google.com/maps/api/staticmap?center=41.399,2.163&zoom=12&size=250x150&markers=color:red|color:red|label:P|41.399,2.163&sensor=false" onclick="cambia()"></td>
  151.     <td width="500" height="180" valign="top">&nbsp;</td>
  152.   </tr>
  153. </body>
  154. </html>

el ejemplo es clicando la imagen del mapa que aparece abajo.

He utilizado $("#mapCanvas").hide(); para ocultarlo cuando se carga la pagina, y al clicar uso lo siguiente $("#mapCanvas").show(2000);


Espero haberme explicado bien, muchas gracias de antemano.

Etiquetas: ajax, efecto, google, html, maps
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:17.