Ver Mensaje Individual
  #7 (permalink)  
Antiguo 04/12/2012, 11:58
helenp
 
Fecha de Ingreso: mayo-2009
Mensajes: 382
Antigüedad: 15 años, 6 meses
Puntos: 6
Respuesta: google map v3, 3 maps on same page

Puf, no veo nada, asi separado me salen dos mapas,
con el mismo nombre de la funcion createmarker me sale solo marcadores en mapa 1,
si cambio el nombre de la funcion createmarker al nombre createmarker2 me sale solo marcadores en mapa 2....

A ver si alguien ve algo mas que se debe de cambiar:

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.     window.onload=function(){
  3.         initialize();
  4.         initialize2();
  5.     }
  6.  </script>
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. var map = null;
  10. function initialize() {
  11.   var myOptions = {
  12.     zoom: 13,
  13.     center: new google.maps.LatLng(36.51308543049258, -4.886341094970703),
  14.     mapTypeControl: true,
  15.     mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
  16.     navigationControl: true,
  17.     mapTypeId: google.maps.MapTypeId.ROADMAP
  18.   }
  19.   map = new google.maps.Map(document.getElementById("map_canvas"),
  20.                                 myOptions);
  21.  
  22.   google.maps.event.addListener(map, 'click', function() {
  23.         infowindow.close();
  24.         });
  25.  
  26.   // Add markers to the map
  27.   // Set up three markers with info windows
  28.  
  29.        
  30.       var point = new google.maps.LatLng(36.50856685143835, -4.866085052490234);
  31.       var marker = createMarker(point,'<div style="width:240px">Banana Beach, several 2 and 3 bedrooms, beach front apartments in a beautiful complex, sleeps 4-6 persons <a href="banana_beach_beachfront_apartment_marbella.htm">Link<\/a><\/div>')
  32.          
  33. }
  34.  
  35. var infowindow = new google.maps.InfoWindow(
  36.   {
  37.     size: new google.maps.Size(150,50)
  38.   });
  39.    
  40. function createMarker(latlng, html) {
  41.     var contentString = html;
  42.     var marker = new google.maps.Marker({
  43.         position: latlng,
  44.         map: map,
  45.         zIndex: Math.round(latlng.lat()*-100000)<<5
  46.         });
  47.        
  48.     google.maps.event.addListener(marker, 'click', function() {
  49.         infowindow.setContent(contentString);
  50.         infowindow.open(map,marker);
  51.         });
  52.         }
  53.  
  54. </script>
  55. <script type="text/javascript">
  56. //<![CDATA[
  57. var map2 = null;
  58. function initialize2() {
  59.  var myOptions2 = {
  60.     zoom: 13,
  61.     center: new google.maps.LatLng(36.488661268293136, -4.986934661865234),
  62.     mapTypeControl: true,
  63.     mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
  64.     navigationControl: true,
  65.     mapTypeId: google.maps.MapTypeId.ROADMAP
  66.   }
  67.   map2 = new google.maps.Map(document.getElementById("map_canvas2"),
  68.                                 myOptions2);
  69.  
  70.   google.maps.event.addListener(map2, 'click', function() {
  71.         infowindow.close();
  72.         });
  73.   // Add markers to the map
  74.   // Set up markers with info windows    
  75.      
  76.         var point =  new google.maps.LatLng(36.502530170146976, -4.951658248901367);
  77.       var marker2 = createMarker(point,'<div style="width:240px">Dama de Noche, apartments 2, 3 and 4 bedrooms, near Puerto Banus and beach, sleeps 4-8 <a href="dama_de_noche_puerto_banus.htm">Link<\/a><\/div>')
  78.          
  79. }
  80.  
  81. var infowindow = new google.maps.InfoWindow(
  82.   {
  83.     size: new google.maps.Size(150,50)
  84.   });
  85.    
  86. function createMarker2(latlng, html) {
  87.     var contentString = html;
  88.          var marker2 = new google.maps.Marker({
  89.         position: latlng,
  90.         map: map2,
  91.         zIndex: Math.round(latlng.lat()*-100000)<<5
  92.         });
  93.        
  94.         google.maps.event.addListener(marker2, 'click', function() {
  95.         infowindow.setContent(contentString);
  96.         infowindow.open(map2,marker2);
  97.         });
  98. }
  99.  </script>