-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmapViewer.js
33 lines (29 loc) · 1.21 KB
/
mapViewer.js
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
$(document).ready(function () {
$.getJSON('result/pic_b_2.json', function (imgInfo) {
var maxZoom = 18;
var minZoom = maxZoom - imgInfo.maxZ + 1;
var map = new BMap.Map('medimg');
map.addControl(new BMap.NavigationControl({
anchor: BMAP_ANCHOR_TOP_RIGHT,
type: BMAP_NAVIGATION_CONTROL_LARGE
}));
map.setMinZoom(minZoom);
map.setMaxZoom(maxZoom);
map.enableScrollWheelZoom();
map.centerAndZoom(new BMap.Point(0, 0), minZoom);
var tileLayer = new BMap.TileLayer();
tileLayer.getTilesUrl = function (tileCoord, zoom) {
var url = 'blank.png';
var zl = maxZoom - zoom;
if ((Math.abs(tileCoord.x + 0.5) <= imgInfo.width / Math.pow(2, zl) / 512 + 0.5) && (Math.abs(tileCoord.y + 0.5) <= imgInfo.height / Math.pow(2, zl) / 512 + 0.5)) {
url = 'precut/pic_b_2' + '_' + zl + '_' + tileCoord.x + '_' + tileCoord.y + '.jpg';
}
return url;
};
map.addTileLayer(tileLayer);
function showInfo(e) {
$('#pos').html(e.point.lng + ", " + e.point.lat);
}
map.addEventListener("click", showInfo);
});
});