-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (67 loc) · 2.49 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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>DGPoi demo</title>
<script src="http://maps.api.2gis.dev/2.0/loader.js?pkg=full&mode=debug&skin=dark"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 600px; border: 1px solid #ccc;"></div>
<script type="text/javascript">
L.onLoad(function () {
var map = new L.Map('map', {
center: new L.LatLng(54.980206086231, 82.898068362003),
zoom: 15,
dgGeoclicker: true,
dgPoi: true
});
var _readWKT =function(selection) {
var _wktParser = L.DG.wkt();
_wktParser.read(selection);
return _wktParser.toObject();
};
var removeFromMap = function(){
if (map.hasLayer(this)){
map.removeLayer(this);
}
}
var getTestpoi = function(z, x, y) {
L.DG.ajax(['/', z, '/', x, '/', y].join(''), {
type : 'jsonp',
success : function(data){
if (data.response.code != 200) return;
var poi = data.result.poi[0],
path = _readWKT(poi.hover);
path.setStyle({
clickable : false,
stroke : false
}).addTo(map);
map.once('viewreset', removeFromMap, path);
}
});
};
var canvasTiles = L.tileLayer.canvas();
canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
var ctx = canvas.getContext('2d');
ctx.fillText(tilePoint.x + ' ' + tilePoint.y, 10, 10);
ctx.beginPath();
ctx.moveTo(255, 0);
ctx.lineTo(255, 255);
ctx.lineTo(0, 255);
ctx.stroke();
getTestpoi(zoom, tilePoint.x, tilePoint.y);
};
map.addLayer(canvasTiles);
map.on('dgPoiHover', function (event) {
console.log('dgPoiHover on poi: ', event);
});
map.on('dgPoiLeave', function (event) {
console.log('dgPoiLeave poi', event);
});
map.on('dgPoiClick', function (event) {
console.log('dgPoiClick poi', event);
});
});
</script>
</body>
</html>