-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
176 lines (157 loc) · 5.17 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<html>
<head>
<meta charset=utf-8 />
<title>Identifying Features</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.css" />
<link rel="stylesheet" href="css/leaflet.draw.css" />
<script src="js/jquery-1.9.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet-src.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.2/esri-leaflet.js"></script>
<script src="js/leaflet.draw.js"></script>
<script src="js/leaflet.identifycontrol.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
</style>
</head>
<body>
<style>
#selectedFeatures {
position: absolute;
top: 10px;
right: 10px;
z-index: 1000;
background: white;
padding: 1em;
}
.leaflet-bar.map-text a {
color: #79BD8F;
display: inline;
}
</style>
<div id="map"></div>
<script>
$(function(){
//初始化
Globle.init();
});
var Globle = {
init: function() {
Globle.map = L.map('map', {
minZoom: 5
}).setView([38.5, -96.8], 6);
L.esri.basemapLayer('Gray').addTo(Globle.map);
Globle.dynamic = L.esri.dynamicMapLayer({
url: 'https://services.arcgisonline.com/arcgis/rest/services/Specialty/Soil_Survey_Map/MapServer',
opacity: 0.7
});
Globle.dynamic.addTo(Globle.map);
Globle.addToolbar();
},
//加载右侧工具条
addToolbar: function() {
var toolbar = L.control({
position: 'topright'
}),
add_marker_div, del_marker_div;
toolbar.onAdd = function() {
var div = L.DomUtil.create('div', 'toolbar');
L.DomUtil.create('div', 'tooldiv', div).innerHTML = '<img class="identify" value="-1" title="点选查询" src="img/toolbar/gongju_search_hover.png" style="width:30px;height:30px;"/>';
L.DomUtil.create('div', 'tooldiv', div).innerHTML = '<img class="default" title="缩放至全图" src="img/toolbar/gongju_quantu_noral.png" style="width:30px;height:30px;"/>';
L.DomUtil.create('div', 'tooldiv', div).innerHTML = '<img class="zoom_in" title="放大" src="img/toolbar/gongju_fangda_noral.png" style="width:30px;height:30px;"/>';
L.DomUtil.create('div', 'tooldiv', div).innerHTML = '<img class="zoom_out" title="缩小" src="img/toolbar/gongju_suoxiao_noral.png" style="width:30px;height:30px;"/>';
return div;
};
toolbar.addTo(Globle.map);
//identify查询
$(".identify").hover(function() {
$(this).attr("src", "img/toolbar/gongju_search_hover.png");
}, function() {
if($(this).attr("value") == "-1") {
$(this).attr("src", "img/toolbar/gongju_search_noral.png");
} else {
$(this).attr("src", "img/toolbar/gongju_search_hover.png");
}
});
$(".identify").click(function() {
if($(this).attr("value") == "-1") {
$(this).attr("value", "1");
$(this).attr("src", "img/toolbar/gongju_search_hover.png");
} else {
$(this).attr("value", "-1");
$(this).attr("src", "img/toolbar/gongju_search_noral.png");
}
});
$(".default").hover(function() {
$(this).attr("src", "img/toolbar/gongju_quantu_hover.png");
}, function() {
$(this).attr("src", "img/toolbar/gongju_quantu_noral.png");
});
$(".zoom_in").hover(function() {
$(this).attr("src", "img/toolbar/gongju_fangda_hover.png");
}, function() {
$(this).attr("src", "img/toolbar/gongju_fangda_noral.png");
});
$(".zoom_out").hover(function() {
$(this).attr("src", "img/toolbar/gongju_suoxiao_hover.png");
}, function() {
$(this).attr("src", "img/toolbar/gongju_suoxiao_noral.png");
});
Globle.zoomToDefault();
Globle.identify();//identify查询事件
Globle.mapZoomIn();//地图放大缩小事件
Globle.mapZoomOut();
},
//缩放到全图
zoomToDefault: function() {
$(".default").click(function() {
Globle.map.setView({
lon: 109.17388916015625,
lat: 38.97468566894531
}, 10);
});
},
//identify查询
identify: function() {
Globle.identifyControl = new L.Control.IdentifyControl({
handler: 'enabled',
identifylayerId: Globle.dynamic._leaflet_id,
identifysuccess: function(data) {
//查询结果显示
alert("identify查询成功,得到数据你就可以为所欲为了!!!");
alert(data.results.length);
console.log(data);
}
}).addTo(Globle.map);
$(".identify").click(function() {
Globle.identifyControl.toggle();
});
},
//地图放大
mapZoomIn: function() {
$(".zoom_in").click(function(e) {
Globle.map.zoomIn();
});
},
//地图缩小
mapZoomOut: function() {
$(".zoom_out").click(function(e) {
Globle.map.zoomOut();
});
}
}
</script>
</body>
</html>