2012-10-12 9 views
5

Ich bin mit der Google Maps-API beschäftigt und es scheint mir nicht möglich zu sein, ein Popup in der Karte hinzuzufügen, das nach dem Klicken auf die benutzerdefinierte Karte Informationen enthält Symbol, das ich hinzugefügt habe. Der Code, den ich verwende, ist unten und ein Beispiel ist auf littlemarketbrasserie.comGoogle Maps API Benutzerdefinierte Pop-Ups

Jede mögliche Hilfe würde sehr geschätzt.

<script type="text/javascript"> 
     function initialize() { 
     var mapOptions = { 
      zoom: 15, 
      panControl: false, 
      mapTypeControl: false, 
      center: new google.maps.LatLng(41.89924, -87.62756), 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 
     var map = new google.maps.Map(document.getElementById('map_canvas'), 
             mapOptions); 

     var image = 'img/lm-logo-maps1.png'; 
     var myLatLng = new google.maps.LatLng(41.89924, -87.62756); 
     var marker = new google.maps.Marker({ 
      position: myLatLng, 
      map: map, 
      animation: google.maps.Animation.DROP, 
      icon: image, 
     }); 

     var styles = [ 
        { 
        stylers: [ 
         { hue: "#ff9f67" }, 
         { saturation: -20 }, 
         { gamma: 1.50 } 
        ] 
        },{ 
        featureType: "road", 
        elementType: "geometry", 
        stylers: [ 
         { lightness: 100 }, 
         { visibility: "simplified" } 
        ] 
        },{ 
        featureType: "road", 
        elementType: "labels.text.stroke", 
        stylers: [ 
         { visibility: "off" } 
        ] 
        }, 

        { 
        featureType: "water", 
        elementType: "geometry.fill", 
        stylers: [ 
         { visibility: "on" }, 
         { color: "#ffa066" }, 
         { lightness: 80 } 
        ] 
        } 
       ]; 

       map.setOptions({styles: styles}); 
     } 
    </script> 

Antwort

6

Wenn Sie sprechen über infowindow dann können Sie in Ihrem initialize Funktion

var popup=new google.maps.InfoWindow({ 
    content: "Hello" 
}); 
google.maps.event.addListener(marker, 'click', function(e) { 
    // you can use event object as 'e' here 
    popup.open(map, this); 
}); 

DEMO.

Auch wenn Sie ein benutzerdefinierter Stil hinzufügen infowindow dann können Sie einen Blick auf this nehmen und this example jQuery Dialog.