2011-02-02 237 views
3

我如何添加一個自定義控件谷歌地圖v3與jQuery的?谷歌地圖api

+0

什麼樣的控制?更多細節請... – Michal 2011-02-02 23:02:44

+0

像地圖類型選擇控制,我想用我自己的控制。 – Amit 2011-02-03 10:24:06

回答

7

您需要確保將自定義控件的元素綁定到您希望它們在地圖上執行的功能,但要使用jQuery添加自定義控件來操作DOM,請執行以下操作:

$(function() { 
    var myOptions = { 
     ... 

     mapTypeControl: false 
    } 

    map = new google.maps.Map($mapDiv, myOptions); 

    ... 


    // Remove the custom control from the DOM to memory 
    $control = $(".myControlSelector").detach(); 

    // Push the control to the top right position on the map 
    map.controls[google.maps.ControlPosition.TOP_RIGHT].push($control[0]); 
}); 

更多文檔位於此處:http://code.google.com/apis/maps/documentation/javascript/controls.html#CustomControls