<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>百度.maps</title>
var marker;
var myIcon;
var state=1;
function initialize() {
map=new BMap.Map('map');
map.centerAndZoom(new BMap.Point(x,y), 19);
window.setTimeout(function(){
countSecond();
}, 2000);
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.addControl(new BMap.MapTypeControl());
myIcon= new BMap.Icon("http://pic.sc.chinaz.com/Files/pic/faces/1384/1.gif", new BMap.Size(70, 70));
marker = new BMap.Marker(new BMap.Point(x,y), {icon: myIcon});
map.addOverlay(marker);
//var tilelayer = new BMap.TileLayer(); // 创建地图层实例
//tilelayer.getTilesUrl=function(){ // 设置图块路径
// return "http://h.hiphotos.baidu.com/image/pic/item/b3119313b07eca80cacfb955922397dda04483be.jpg";
//};
//map.addTileLayer(tilelayer);
//var opts = {
// width : 200,
// height: 300,
// title : "我家"
//}
//var infoWindow = new BMap.InfoWindow("<img src='http://images.haiwainet.cn/2015/0512/20150512012117512.jpg'>", opts); // 创建信息窗口对象
//map.openInfoWindow(infoWindow, map.getCenter());
}
function countSecond()
{
if(state==1){
y=y+0.000010;
if(y>=34.220680){
state=2;
}
}
if(state==2){
x=x+0.000010;
if(x>=108.953000){
state=3;
}
}
if(state==3){
y=y+0.000010;
if(y>=34.224600){
state=4;
}
}
if(state==4){
x=x+0.000010;
if(x>=108.955100){
state=5;
}
}
if(state==5){
clearTimeout(xx);
}
map.removeOverlay(marker);
marker = new BMap.Marker(new BMap.Point(x,y), {icon: myIcon});
map.addOverlay(marker);
map.centerAndZoom(new BMap.Point(x, y), 19);
var xx=setTimeout("countSecond()", 1)
}
function loadScript() {
var script = document.createElement("script");
script.src = "http://api.map.baidu.com/api?v=1.5&ak=knEf6zSDw9Wcc9koiGtMkH7a&callback=initialize";//此为v1.5版本的引用方式
// http://api.map.baidu.com/api?v=1.5&ak=您的密钥&callback=initialize"; //此为v1.4版本及以前版本的引用方式
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
<style type="text/css">
html{height:100%}
body{height:100%;margin:0px;padding:0px}
</style>
</head>
<body>
<div id="map" style="width:auto;height:800px"></div>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>百度.maps</title>
<script>
//设置随意经纬度
var x=108.950718;var y=34.219718;
//实例map
var map;var marker;
var myIcon;
var state=1;
function initialize() {
map=new BMap.Map('map');
map.centerAndZoom(new BMap.Point(x,y), 19);
window.setTimeout(function(){
countSecond();
}, 2000);
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.addControl(new BMap.MapTypeControl());
myIcon= new BMap.Icon("http://pic.sc.chinaz.com/Files/pic/faces/1384/1.gif", new BMap.Size(70, 70));
marker = new BMap.Marker(new BMap.Point(x,y), {icon: myIcon});
map.addOverlay(marker);
//var tilelayer = new BMap.TileLayer(); // 创建地图层实例
//tilelayer.getTilesUrl=function(){ // 设置图块路径
// return "http://h.hiphotos.baidu.com/image/pic/item/b3119313b07eca80cacfb955922397dda04483be.jpg";
//};
//map.addTileLayer(tilelayer);
//var opts = {
// width : 200,
// height: 300,
// title : "我家"
//}
//var infoWindow = new BMap.InfoWindow("<img src='http://images.haiwainet.cn/2015/0512/20150512012117512.jpg'>", opts); // 创建信息窗口对象
//map.openInfoWindow(infoWindow, map.getCenter());
}
function countSecond()
{
if(state==1){
y=y+0.000010;
if(y>=34.220680){
state=2;
}
}
if(state==2){
x=x+0.000010;
if(x>=108.953000){
state=3;
}
}
if(state==3){
y=y+0.000010;
if(y>=34.224600){
state=4;
}
}
if(state==4){
x=x+0.000010;
if(x>=108.955100){
state=5;
}
}
if(state==5){
clearTimeout(xx);
}
map.removeOverlay(marker);
marker = new BMap.Marker(new BMap.Point(x,y), {icon: myIcon});
map.addOverlay(marker);
map.centerAndZoom(new BMap.Point(x, y), 19);
var xx=setTimeout("countSecond()", 1)
}
function loadScript() {
var script = document.createElement("script");
script.src = "http://api.map.baidu.com/api?v=1.5&ak=knEf6zSDw9Wcc9koiGtMkH7a&callback=initialize";//此为v1.5版本的引用方式
// http://api.map.baidu.com/api?v=1.5&ak=您的密钥&callback=initialize"; //此为v1.4版本及以前版本的引用方式
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
<style type="text/css">
html{height:100%}
body{height:100%;margin:0px;padding:0px}
</style>
</head>
<body>
<div id="map" style="width:auto;height:800px"></div>
</body>
</html>