|
作业来源是这里:http://lbsbbs.amap.com/forum.php?mod=viewthread&tid=1436
看完第一段视频,知道要完成4个控件,和2个插件。
找到4个控件的示例:http://lbs.amap.com/api/javascript-api/example/c/0304-2/
找到2个插件的示例:http://lbs.amap.com/api/javascript-api/example/f/0604-2/
拷贝上面的代码,改吧改吧,如下:
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>zhangying02</title>
- <style type="text/css">
- body{
- margin:0;
- height:100%;
- width:100%;
- position:absolute;
- }
- #mapContainer{
- position: absolute;
- top:0;
- left: 0;
- right:0;
- bottom:0;
- }
-
- #btnDiv{
- position:absolute;
- bottom: 0;
- right:10px;
- height:80px;
- font-size:12px;
- }
-
- #btnDiv input{
- height:23px;
- outline:none;
- border:1px solid #ddd;
- padding-left:5px;
- border-radius:3px;
- }
-
- #btnDiv input[type='button']{
- height:28px;
- line-height:28px;
- outline:none;
- text-align:center;
- padding-left:5px;
- padding-right:5px;
- color:#FFF;
- background-color:#0D9BF2;
- border:0;
- border-radius: 3px;
- margin-top:5px;
- margin-left:5px;
- cursor:pointer;
- margin-right:10px;
- }
- </style>
- </head>
- <body>
- <div id="mapContainer"></div>
- <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=【key您还是自己申请一个】"></script>
- <script type="text/javascript">
- var overView;
- var mapType;
- var scale;
- var toolBar;
- var mousetool;
-
- //初始化地图对象,加载地图
- var map = new AMap.Map("mapContainer", {
- resizeEnable: true,
- view: new AMap.View2D({
- center: new AMap.LngLat(116.397428,39.90923),
- zoom: 13
- }),
- });
- //1
- map.plugin(["AMap.OverView"],function(){
- overView = new AMap.OverView();
- map.addControl(overView);
- overView.show();
- });
- //2
- map.plugin(["AMap.MapType"],function(){
- mapType = new AMap.MapType();
- map.addControl(mapType);
- mapType.show();
- });
- //3
- map.plugin(["AMap.Scale"],function(){
- scale = new AMap.Scale();
- map.addControl(scale);
- scale.show();
- });
- //4
- map.plugin(["AMap.ToolBar"],function(){
- toolBar = new AMap.ToolBar();
- map.addControl(toolBar);
- toolBar.show();
- });
-
- //测面积
- map.plugin(["AMap.MouseTool"],function(){
- mousetool = new AMap.MouseTool(map);
- mousetool.measureArea(); //使用鼠标工具,在地图上画标记点
- });
- </script>
- </body>
- </html>
复制代码
效果图:
赶紧发送以上代码给那个雨久!就能得到个人认证证书!!!
刘叶维(雨久) <yewei.liu@alibaba-inc.com>
|
|