Skip to content

Commit 90102c3

Browse files
author
潘卓然-中地数码台式机
committed
补充igserver-x的分类
1 parent b00f735 commit 90102c3

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

  • demo/leaflet/example/igserverx/socket
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6+
<title>Draw</title>
7+
<script src="../../libs/zondyclient/include-leaflet-local.js"></script>
8+
<style>
9+
#map {
10+
height: 800px;
11+
}
12+
</style>
13+
</head>
14+
15+
<body>
16+
<div id="map"></div>
17+
<script>
18+
var map = new L.Map("map", {
19+
center: new L.LatLng(34.218216, 108.835846),
20+
zoom: 15
21+
});
22+
var osm = L.tileLayer(
23+
"https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=" +
24+
"sk.eyJ1IjoiY2hlbmdkYWRhIiwiYSI6ImNqZDFjaGo0ZjFzcnoyeG54enoxdnNuZHUifQ.hTWXXBUQ0wdGeuDF3GWeUw", {
25+
attribution: '<a href="#">Mapbox</a>',
26+
maxZoom: 18,
27+
id: "mapbox.streets"
28+
}
29+
).addTo(map);
30+
var urlData = "ws://192.168.91.121:9382/flowdata/streamdemo";
31+
var popup = L.popup({
32+
offset: L.point(0, 0),
33+
autoPan: true
34+
});
35+
var streamLayer = L.zondy.StreamLayer(map, urlData, {
36+
style: function (feature) {
37+
return {
38+
fillColor: "#ffff00",
39+
fillOpacity: 1,
40+
radius: 10,
41+
weight: 0
42+
};
43+
},
44+
field: "imei" //这个属性必须传入,如果没有则使用默认字段id
45+
});
46+
streamLayer.on("layerupdate", function (result) {
47+
var feature = result.data;
48+
var content = "速度:" + feature.properties.speed +
49+
"公里/时 设备号:" + feature.properties.imei;
50+
popup
51+
.setLatLng(L.GeoJSON.coordsToLatLng(feature.geometry.coordinates))
52+
.setContent(content);
53+
if (!popup.isOpen()) {
54+
popup.addTo(map);
55+
}
56+
});
57+
streamLayer.addTo(map);
58+
</script>
59+
</body>
60+
61+
</html>

0 commit comments

Comments
 (0)