5

Google Maps API をいじっていますが、追加したカスタム マップ アイコンをクリックした後に情報を表示するポップアップをマップ内に追加する方法がわかりません。私が使用しているコードは以下で、例はlittlemarketbrasserie.comにあります

どんな助けでも大歓迎です。

<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>
4

1 に答える 1

6

あなたが話している場合は、関数infowindow内で使用できますinitialize

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);
});

デモ

また、カスタム スタイルを追加する場合は、 jQuery ダイアログを使用してthisおよびthis exampleinfowindowを参照してください。

于 2012-10-12T22:46:11.737 に答える