0

以下の例のように、GMaps.jsを使用してマップにコンテキストメニューを追加することができました。

map.setContextMenu({
  control: 'map',
    options: [{
        title: 'Add marker',
        name: 'add_marker',
        action: function(e) {
            this.addMarker({
              lat: e.latLng.lat(),
              lng: e.latLng.lng(),
              title: 'New marker'
            });
        }
    }, {
        title: 'Center here',
        name: 'center_here',
        action: function(e) {
        this.setCenter(e.latLng.lat(), e.latLng.lng());
    }
  }]
});

ただし、マーカーにコンテキストメニューを追加できないようです。

誰かがこれを行う方法を投稿できますか

ありがとう

4

2 に答える 2

1

このコードは私にとって完璧に機能します。また、 contextMenu が表示されない場合は、右クリックしてメニューを表示してみてください!!

map.setContextMenu({
        control: 'map',
        options: [{
            title: 'Add marker',
            name: 'add_marker',
            action: function(e){
                this.addMarker({
                    lat: e.latLng.lat(),
                    lng: e.latLng.lng(),
                    animation: google.maps.Animation.DROP,
                    draggable:true,
                    title: 'New Marker'
                });
                this.hideContextMenu();
            }
        }, {
            title: 'Center here',
            name: 'center_here',
            action: function(e){
                this.setCenter(e.latLng.lat(), e.latLng.lng());
            }
        }]
    });
    map.setContextMenu({
        control: 'marker',
        options: [{
            title: 'Center here',
            name: 'center_here',
            action: function(e){
                this.setCenter(e.latLng.lat(), e.latLng.lng());
            }
        }]
    });

gmaps でマップを右クリック

于 2015-09-17T05:01:38.940 に答える
0

ここでデモされている infoWindow のことですか? http://hpneo.github.com/gmaps/examples/markers.html

そのページのソースを見ると、追加するだけでよいことがわかります

infoWindow: {
    content: '<p>HTML Content</p>'
}

addMarker ビットに、つまり タイトルの下。それは本当に簡単です!:)

于 2012-12-14T11:50:35.000 に答える