首页 > 移动平台 > 详细

百度地图-定时器移动地图

时间:2016-05-12 22:42:46      阅读:180      评论:0      收藏:0      [点我收藏+]

1、问题背景

     打开地图默认为武汉市,过了5秒中后地图定位到黄冈市,再过5秒定位到上海市


2、实现源码

<!DOCTYPE html>
<html>
  <head>
    <title>定时器移动地图</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ak密钥"></script>
    <style>
    	body, html {
    		width: 100%;
    		height: 100%;
    		margin:0;
    		font-family:"微软雅黑";
    	}
		#map{
			width:100%;
			height: 100%;
		}
    </style>

  </head>
  
  <body>
     <div id="map"></div>
  </body>
</html>
<script>
    var map = new BMap.Map("map");
    //设置默认城市武汉市
    map.centerAndZoom(new BMap.Point(114.309531, 30.59619),18); 
    
    setTimeout(function(){
        //移动到黄冈市
		map.panTo(new BMap.Point(114.880597,30.459173));   
	}, 5000);
	setTimeout(function(){
        //移动到上海市
		map.panTo(new BMap.Point(121.477362,31.236058));   
	}, 10000);
</script>

3、实现结果

(1)初始化时

技术分享


(2)过了5秒后

技术分享


(3)再过5秒

技术分享

百度地图-定时器移动地图

原文:http://blog.csdn.net/you23hai45/article/details/51348328

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!