2009-07-21 11 views

答えて

-2

まだありません。 Googleが今作業しています。

1

古い質問が、私は、私は最も簡単な答えを投稿だろうと思ったので、それは私のグーグルで思い付い。他のサードパーティのjsライブラリを使用しないコンテキストメニューです。あなたがクリックした場所の緯度/経度を取得したり、メーカーなどを追加したりすることができるイベントには、latlonオブジェクトもあります。

var contextMenu = google.maps.event.addListener(
     map, 
     "rightclick", 
     function (event) { 
      // use JS Dom methods to create the menu 
      // use event.pixel.x and event.pixel.y 
      // to position menu at mouse position 


      $('.contextmenu').remove(); //remove previous context menus 
      contextmenuDir = document.createElement("div"); 
      contextmenuDir.className = 'contextmenu'; 
      //now add our options. 
      contextmenuDir.innerHTML = '<a id="menu1"><div class="context">menu item 1<\/div><\/a>' 
            + '<a id="menu2"><div class="context">menu item 2<\/div><\/a>'; 

      $(map.getDiv()).append(contextmenuDir); 

      contextmenuDir.style.visibility = "visible"; 

       // might need to offset if you have moved the map div like i did (then - the pixel size off) 
       $('.contextmenu').css('left', event.pixel.x); 
       $('.contextmenu').css('top', event.pixel.y); 

       console.log(event); //log some details about the object we get 
      }); 
+0

>「他のサードパーティのjsライブラリを使用しないでください」ルックそのコードでJqueryを使用しているようです。 – Gerry

+0

ああ、私はそこに再フェイズさせてください。余分なサードパーティのマッピングライブラリなしで動作します。 – Mark

関連する問題