Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/06/2015, 02:33
Avatar de SirZoX
SirZoX
 
Fecha de Ingreso: mayo-2006
Ubicación: Valencia
Mensajes: 124
Antigüedad: 18 años
Puntos: 2
Respuesta: Añadir cuadro "como llegar" en la api 3 de google maps

Hola.

Gracias yoyo_38tuzo por la respuesta, pero no funciona tampoco así.
El mapa que yo cargo lleva una capa de personalización del propio mapa. Usando el código tal como me comentas trae un resultado en el que mi capa de personalización desaparece, y además tampoco me muestra el box con las opciones del "como llegar" y demás.

Yo cargo el mapa directamente sin un enlace, sino con un div "vacio" que luego google maps llena por sí mismo.
Código HTML:
Ver original
  1. <div id="map-frame"></div>

Y con JS luego cargo tanto la capa de personalización como el marcador y otras cosas.

Código Javascript:
Ver original
  1. function initialize() {
  2.     var styles = [{"stylers":[{"saturation":-100},{"gamma":1}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"saturation":50},{"gamma":0},{"hue":"#50a5d1"}]},{"featureType":"administrative.neighborhood","elementType":"labels.text.fill","stylers":[{"color":"#333333"}]},{"featureType":"road.local","elementType":"labels.text","stylers":[{"weight":0.5},{"color":"#333333"}]},{"featureType":"transit.station","elementType":"labels.icon","stylers":[{"gamma":1},{"saturation":50}]}];
  3.     var latlng = new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx  );
  4.     var myOptions = {
  5.         zoom: 16,
  6.         center: latlng,
  7.         mapTypeId: google.maps.MapTypeId.ROADMAP,
  8.         disableDefaultUI: true,
  9.         styles: styles
  10.     };
  11.  
  12.     map = new google.maps.Map(document.getElementById('map-frame'), myOptions);
  13.    
  14.     //definimos las coordenadas del área
  15.     var trmCoords = [
  16.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  17.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  18.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  19.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  20.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  21.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  22.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx),
  23.         new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx)
  24.     ];
  25.  
  26.     //construimos el polígono
  27.     var areaTRM = new google.maps.Polygon({
  28.         paths: trmCoords,
  29.         strokeColor: '#f8bf18',
  30.         strokeOpacity: 0,
  31.         fillColor: '#CF0D29',
  32.         fillOpacity: 0.6
  33.     });
  34.  
  35.    
  36.     areaTRM.setMap(map);
  37.  
  38.  
  39.     var marcador = new google.maps.Marker({                                        
  40.         position: new google.maps.LatLng(xx.xxxxxxxx, xx.xxxxxxxxx   ),                                
  41.         // 
  42.         map: map,
  43.         icon: 'images/logo-map.png',
  44.         animation: google.maps.Animation.DROP
  45.     });
  46.  
  47.    
  48.  
  49. }
  50.  
  51. google.maps.event.addDomListener(window,'load', initialize);