mapLevel.js
1.58 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
37
38
39
40
41
42
43
var mapLevel = {
loadLevelControl:function (map) {
var level = map.getZoom();
// var html = '<div style=\'position:fixed; z-index:9999;bottom: 20px;right: 10px;\'>' +
// '<table border="1" style="width: 55px;height: 58px;text-align: center;">' +
// '<tr>' +
// '<td colspan="2" style="background: #707070;color: #FFFFFF" id="map_level">'+level+'</td>' +
// '</tr><tr>' +
// '<td style="background: #FFFFFF" id="level_minus"><img src="src/image/btn5.png"></td>' +
// '<td style="background: #FFFFFF" id="level_plus"><img src="src/image/btn4.png"></td>' +
// '</tr>' +
// '</table>' +
// '</div>';
var html = '<div style="position:absolute; z-index:9999;bottom: 10%;left: 2%;">' +
'<div id="level_plus"><img src="src/image/btn4.png"></div>' +
'<div style="margin-top: 10px;" id="level_minus"><img src="src/image/btn5.png"></div>' +
'</div>';
$('body').append(html);
$('#level_minus').click(function () {
var zoom = map.getZoom();
if (zoom>0 && zoom<18){
zoom --;
}
map.zoomTo(zoom);
// $('#map_level').html(zoom);
});
$('#level_plus').click(function () {
var zoom = map.getZoom();
if (zoom>0 && zoom<18){
zoom ++;
}
map.zoomTo(zoom);
// $('#map_level').html(zoom);
});
},
setLevel:function (level) {
$('#map_level').html(level);
}
}