如何使用jquery向谷歌地图v3添加自定义控件?
发布于 2011-02-04 23:43:53
您需要确保将自定义控件的元素绑定到您希望它们在地图本身上执行的功能,但是要使用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
发布于 2011-06-04 09:52:37
其中一个示例使用jQuery Google Maps plugin添加标记过滤控件,请参见底部附近的"Filter Markers Example“。
安卓应用程序使用相同的jQuery插件和类似的示例here (来源可用,手机/平板电脑/桌面)。
https://stackoverflow.com/questions/4875524
复制相似问题