1. 地图缩放控件
(1)全能控件——GLargeMapControl
(2)微型化控件——GSmallMapControl
(3)微型缩放控件——GSmallZoomControl
2.地图类型选择控件
(1)按钮式标准控件——GMapTypeControl
(2)菜单式控件——GMenuTypeControl
(3)阶层式标准控件——GhierarchicalMapTypeControl
3.缩略图控件——GOverviewMapControl
4.比例尺控件——GScaleControl
如何添加控件:
map.addControl(new GLargeMapControl());
map.addControl(new GLargeMapControl(),new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(10,10)));
GControlPosition决定控件的位置,可选参数;
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script
src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN"
type="text/javascript"></script>
<script type="text/javascript">
function load(){
//检查浏览器的兼容性.
if (GBrowserIsCompatible()){
//加载地图
var map=new GMap2(document.getElementById("mapCanvas"));
//设置地图的中心坐标.
map.setCenter(new GLatLng(39.990168,116.295304),4);
//允许用户移动和缩放地图
map.addControl(new GSmallMapControl());
//允许用户在地图类型之间切换
map.addControl(new GMapTypeControl());
}
}
</script>
</head>
<body onload="load()" onunload="GUnload()">
<!-- 地图画板 -->
<div id="mapCanvas" style="640px; height:480px"></div>
</body>
</html>