如何使用jQuery将自定义控件添加到Google Maps v3中?
如何使用jQuery将自定义控件添加到Google Maps v3中?
您需要确保将自定义控件的元素绑定到您希望它们在地图上执行的功能,但是要使用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
var $control
吧? - Odys