-
Notifications
You must be signed in to change notification settings - Fork 1
/
gdmap.html
66 lines (55 loc) · 2.01 KB
/
gdmap.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
55
56
57
58
59
60
61
62
63
64
65
66
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<link rel="stylesheet" type="text/css" href="https://a.amap.com/jsapi_demos/static/demo-center/css/prety-json.css">
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
<title>获取搜索信息</title>
</head>
<body>
<div id="container"></div>
<div class="info">
<h4>搜索结果展示</h4>
<p><span id="input-info"></span></p>
</div>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=c402e9f4b6dc87cf70727f8dd7f22dc8&plugin=AMap.PlaceSearch"></script>
<script type="text/javascript" src="https://a.amap.com/jsapi_demos/static/demo-center/js/jquery-1.11.1.min.js" ></script>
<script type="text/javascript" src="https://a.amap.com/jsapi_demos/static/demo-center/js/underscore-min.js" ></script>
<script type="text/javascript" src="https://a.amap.com/jsapi_demos/static/demo-center/js/backbone-min.js" ></script>
<script type="text/javascript" src='https://a.amap.com/jsapi_demos/static/demo-center/js/prety-json.js'></script>
<script>
// 初始化地图
var map = new AMap.Map("container", {
resizeEnable: true
});
// 获取搜索信息
function autoInput(){
var keywords = '北京大学';
AMap.plugin('AMap.PlaceSearch', function(){
var autoOptions = {
city: '全国'
}
var placeSearch = new AMap.PlaceSearch(autoOptions);
placeSearch.search(keywords, function(status, result) {
// 搜索成功时,result即是对应的匹配数据
var node = new PrettyJSON.view.Node({
el: document.querySelector("#input-info"),
data: result
});
})
})
}
autoInput();
</script>
</body>
</html>