forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonlineWebMap.html
More file actions
36 lines (36 loc) · 1.4 KB
/
onlineWebMap.html
File metadata and controls
36 lines (36 loc) · 1.4 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>2014当了一回背包客</title>
<script type="text/javascript" src="../../dist/include-openlayers.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
<div id="map" style="width: 100%;height:100%"></div>
<div id="popup" class="ol-popup"
style="background-color: white;padding: 15px;border-radius: 10px;border: 1px solid #cccccc;">
<div id="popup-content"></div>
</div>
<script type="text/javascript">
new ol.supermap.WebMap(128).addEventListener(ol.supermap.WebMap.EventType.WEBMAPLOADEND, function (e) {
var map = e.value;
var popup = new ol.Overlay({
element: document.getElementById('popup')
});
map.addOverlay(popup);
map.on('click', function (evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function (feature) {
return feature;
}, {hitTolerance: 10});
if (feature) {
popup.setPosition(evt.coordinate);
document.getElementById('popup-content').innerHTML = feature.getProperties().attributes.title + ":" + feature.getProperties().attributes.description;
} else {
popup.setPosition();
}
})
});
</script>
</body>
</html>