-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
121 lines (112 loc) · 4.62 KB
/
index.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!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">
<title>PhotoMap</title>
<link rel="stylesheet" href="./css/main1119.css" />
<style type="text/css">
.amap-marker-content {
position: relative;
}
.marker_area {
width: 44px;
height: 34px;
padding: 5px 23px 13px 5px;
background: url(https://ditu.amap.com/assets/img/livephoto_aera.png) center center no-repeat;
background-size: cover;
position: relative;
cursor: pointer;
}
.photo_thumb {
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 100%;
}
.marker_area .marker_area_name {
display: none;
position: absolute;
left: 14px;
bottom: 20px;
color: #333;
padding-left: 20px;
height: 24px;
line-height: 24px;
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background: url(https://ditu.amap.com/assets/img/photo_loc_icon.png) left center no-repeat;
}
.marker_area.photo_hover .marker_area_name {
display: block;
}
.marker_area.photo_hover {
bottom: 109px;
left: -71px;
width: 184px;
height: 106px;
padding: 9px 52px 48px 9px;
background: url(https://ditu.amap.com/assets/img/photo_hover.png) center center no-repeat;
background-size: cover;
}
</style>
<script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=ddb4718923a922a569a1484c59a47ed7"></script>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
var map = new AMap.Map("container", {
resizeEnable: true,
center: [116.397428, 39.90923], //地图中心点
zoom: 13 //地图显示的缩放级别
});
map.clearMap(); // 清除地图覆盖物
var markers = [{
name: '天安门',
icon: 'https://aos-cdn-image.amap.com/sns/ugc/photo/ddef3ad045b743dfa1464e83cefc35b7.jpg',
position: [116.397428, 39.90923]
}, {
name: 'giscafer',
icon: 'https://avatars0.githubusercontent.com/u/8676711?v=3&s=460',
position: [116.368904, 39.913423]
}, {
name: 'gis520',
icon: 'https://avatars0.githubusercontent.com/u/17235971?v=3&s=200',
position: [116.335467, 39.907761]
}];
// 添加一些分布不均的点到地图上,地图上添加三个点标记,作为参照
markers.forEach(function(marker) {
new AMap.Marker({
map: map,
position: [marker.position[0], marker.position[1]],
offset: new AMap.Pixel(-17, -42), //相对于基点的偏移位置
draggable: false, //是否可拖动
content: '<div class="marker_area"><div class="photo_thumb" style="background-image:url(' + marker.icon + '@200h)"></div><span class="marker_area_name">' + marker.name + '</span></div>' //
});
});
window.onload = function() {
map.plugin(["AMap.ToolBar"], function() {
map.addControl(new AMap.ToolBar());
});
};
var newCenter = map.setFitView();
var mapContainer = $("#container");
mapContainer.on("mouseenter", ".marker_area", function() {
$(this).addClass("photo_hover"), s = $(this).closest(".amap-marker").attr("style"), $(this).closest(".amap-marker").addClass("hover"), map.set("isHotspot", !1)
});
mapContainer.on("mouseleave", ".marker_area", function() {
$(this).removeClass("photo_hover"), $(this).closest(".amap-marker").removeClass("hover"), map.set("isHotspot", !0)
});
/*mapContainer.on("click", ".marker_area", function(){
console.log(111);
$(this).addClass("photo_hover"), s = $(this).closest(".amap-marker").attr("style"), $(this).closest(".amap-marker").addClass("hover"), map.set("isHotspot", !1)
});*/
</script>
<a href="https://github.com/gis520/amap-photomap"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
</body>
</html>