-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.html
54 lines (51 loc) · 1.77 KB
/
map.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
#allmap{width:100%;height:800px;}
p{margin-left:5px; font-size:14px;}
</style>
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>-->
<title>根据关键字本地搜索</title>
</head>
<body>
<div id="allmap"></div>
<p>返回北京市“景点”关键字的检索结果,并展示在地图上</p>
</body>
<script type="text/javascript">
// 百度地图API功能
// var map = new BMap.Map("allmap");
// map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
// var local = new BMap.LocalSearch(map, {
// renderOptions:{map: map}
// });
// local.search("广东广州天河信息港F栋");
//
// // 百度地图API功能
// setTimeout(function(){
// map.setZoom(14);
// }, 2000); //2秒后放大到14级
// map.enableScrollWheelZoom(true);
//百度地图API功能
function loadJScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://api.map.baidu.com/api?v=1.4&callback=init";
document.body.appendChild(script);
}
function init() {
var map = new BMap.Map("allmap"); // 创建Map实例
var point = new BMap.Point(116.404, 39.915); // 创建点坐标
map.centerAndZoom(point,15);
map.enableScrollWheelZoom(); //启用滚轮放大缩小
var local = new BMap.LocalSearch(map, {
renderOptions:{map: map}
});
local.search("广东广州天河信息港F栋");
}
window.onload = loadJScript; //异步加载地图
</script>
</html>