|
|
@@ -45,6 +45,9 @@ window.onload = function() {
|
|
45
|
45
|
if(point) {
|
|
46
|
46
|
//定位到区 ,级别显示12
|
|
47
|
47
|
map.centerAndZoom(point, 13);
|
|
|
48
|
+ $(".store_Lng").val(point.lng);
|
|
|
49
|
+
|
|
|
50
|
+ $(".store_Lat").val(point.lat);
|
|
48
|
51
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
|
49
|
52
|
//删除选点
|
|
50
|
53
|
map.clearOverlays();
|
|
|
@@ -95,8 +98,10 @@ window.onload = function() {
|
|
95
|
98
|
//#region 百度地图相关代码
|
|
96
|
99
|
/*************************百度地图 **************************/
|
|
97
|
100
|
function loadDefulatMap(callback) {
|
|
|
101
|
+
|
|
98
|
102
|
var longiTude=$(".store_Lng").val();
|
|
99
|
103
|
var latitude=$(".store_Lat").val();
|
|
|
104
|
+ console.log(longiTude)
|
|
100
|
105
|
var point = new BMap.Point($(".store_Lng").val(), $(".store_Lat").val()); // 创建点坐标
|
|
101
|
106
|
map.centerAndZoom(point, 15); // 初始化地图,设置中心点坐标和地图级别
|
|
102
|
107
|
map.addControl(new BMap.NavigationControl());
|
|
|
@@ -125,6 +130,7 @@ window.onload = function() {
|
|
125
|
130
|
// var myGeo = new BMap.Geocoder();
|
|
126
|
131
|
myGeo.getPoint(address, function(point) {
|
|
127
|
132
|
if(point) {
|
|
|
133
|
+
|
|
128
|
134
|
//定位到区 ,级别显示12
|
|
129
|
135
|
map.centerAndZoom(point, 13);
|
|
130
|
136
|
//删除选点
|
|
|
@@ -175,11 +181,11 @@ window.onload = function() {
|
|
175
|
181
|
})
|
|
176
|
182
|
}
|
|
177
|
183
|
//地图选点点击事件
|
|
178
|
|
-// function clickCoordinate(e) {
|
|
179
|
|
-// var point = e.point;
|
|
180
|
|
-// createMarker(point);
|
|
181
|
|
-// console.log(e.point);
|
|
182
|
|
-// }
|
|
|
184
|
+ function clickCoordinate(e) {
|
|
|
185
|
+ var point = e.point;
|
|
|
186
|
+ createMarker(point);
|
|
|
187
|
+ console.log(e.point);
|
|
|
188
|
+ }
|
|
183
|
189
|
|
|
184
|
190
|
function setPlace(value) {
|
|
185
|
191
|
function myFun() {
|
|
|
@@ -219,6 +225,7 @@ window.onload = function() {
|
|
219
|
225
|
}
|
|
220
|
226
|
|
|
221
|
227
|
function createMarker(point, isLoad) {
|
|
|
228
|
+
|
|
222
|
229
|
//反向解析地址
|
|
223
|
230
|
myGeo.getLocation(point, function(rs) {
|
|
224
|
231
|
map.clearOverlays(); //清除之前所有的标志
|
|
|
@@ -226,6 +233,7 @@ window.onload = function() {
|
|
226
|
233
|
var marker = new BMap.Marker(point); // 创建标注
|
|
227
|
234
|
map.addOverlay(marker); // 将标注添加到地图中
|
|
228
|
235
|
marker.enableDragging(); //可拖拽 自定义拖拽
|
|
|
236
|
+
|
|
229
|
237
|
//拖拽前事件
|
|
230
|
238
|
marker.addEventListener("dragstart", function(e) {
|
|
231
|
239
|
baiduParam.oldPoint = e.point;
|
|
|
@@ -245,11 +253,11 @@ window.onload = function() {
|
|
245
|
253
|
// }
|
|
246
|
254
|
//如果缩放等级小于当前的 ,则为18
|
|
247
|
255
|
if(map.getZoom() < 18) {
|
|
248
|
|
- map.setZoom(18);
|
|
|
256
|
+ map.setZoom(13);
|
|
249
|
257
|
}
|
|
250
|
258
|
//解析地址
|
|
251
|
259
|
var rsaddress = rs.address;
|
|
252
|
|
- console.log(rs);
|
|
|
260
|
+ console.log(rs,rsaddress);
|
|
253
|
261
|
console.log(rs.addressComponents.district)
|
|
254
|
262
|
// if (rs.addressComponents.district=="汤阴县") {
|
|
255
|
263
|
// $('#sourcearea').val("2");
|
|
|
@@ -272,19 +280,20 @@ window.onload = function() {
|
|
272
|
280
|
// }else if (rs.addressComponents.district=="文峰区"){
|
|
273
|
281
|
// $('#sourcearea').val("11");
|
|
274
|
282
|
// }
|
|
275
|
|
- $('#sourcearea').find("option:selected").text(rs.addressComponents.district);
|
|
276
|
|
- //$('#sourcearea').find("option:selected").val(rs.addressComponents.district);
|
|
277
|
|
- if (rs.surroundingPois.length>0) {
|
|
278
|
|
- if (rs.addressComponents.street!="") {
|
|
279
|
|
- $('#sourceaddress').val(rs.addressComponents.street+'-'+rs.surroundingPois[0].title);
|
|
280
|
|
- }else{
|
|
281
|
|
- $('#sourceaddress').val(rs.surroundingPois[0].title);
|
|
282
|
|
- }
|
|
|
283
|
+ // $('#sourcearea').find("option:selected").text(rs.addressComponents.district);
|
|
|
284
|
+ // //$('#sourcearea').find("option:selected").val(rs.addressComponents.district);
|
|
|
285
|
+ // if (rs.surroundingPois.length>0) {
|
|
|
286
|
+ // if (rs.addressComponents.street!="") {
|
|
|
287
|
+ // $('#sourceaddress').val(rs.addressComponents.street+'-'+rs.surroundingPois[0].title);
|
|
|
288
|
+ // }else{
|
|
|
289
|
+ // $('#sourceaddress').val(rs.surroundingPois[0].title);
|
|
|
290
|
+ // }
|
|
283
|
291
|
|
|
284
|
|
- }else{
|
|
285
|
|
- $('#sourceaddress').val(rs.addressComponents.street);
|
|
286
|
|
- }
|
|
|
292
|
+ // }else{
|
|
|
293
|
+ // $('#sourceaddress').val(rs.addressComponents.street);
|
|
|
294
|
+ // }
|
|
287
|
295
|
$(".store_Lng").val(rs.point.lng);
|
|
|
296
|
+
|
|
288
|
297
|
$(".store_Lat").val(rs.point.lat);
|
|
289
|
298
|
var rstitle = rs.surroundingPois[0] != null ? rs.surroundingPois[0].title : "";
|
|
290
|
299
|
html = html.replace("{address}", rsaddress).replace("{title}", rstitle);
|
|
|
@@ -312,6 +321,7 @@ window.onload = function() {
|
|
312
|
321
|
infoWindow.setContent("<img style='width:20px;top: -2px;position: relative;' src='img/success.png' />已将坐标定位为<hr/>" + rs.address + "<br/><small style='color: #858585;line-height: 24px;'>地址:" + (rs.surroundingPois[0] != null ? rs.surroundingPois[0].title : "") + "</small><br/><br/>");
|
|
313
|
322
|
$(".store_Lng").val(rs.point.lng);
|
|
314
|
323
|
$(".store_Lat").val(rs.point.lat);
|
|
|
324
|
+ console.log($(".store_Lat").val(rs.point.lat))
|
|
315
|
325
|
})
|
|
316
|
326
|
});
|
|
317
|
327
|
/******** 图层初始化 ********/
|
|
|
@@ -365,7 +375,7 @@ window.onload = function() {
|
|
365
|
375
|
bindEvent();
|
|
366
|
376
|
function bindEvent() {
|
|
367
|
377
|
//查询百度地图
|
|
368
|
|
- //map.addEventListener("click", clickCoordinate); //地图点击事件
|
|
|
378
|
+ map.addEventListener("click", clickCoordinate); //地图点击事件
|
|
369
|
379
|
}
|
|
370
|
380
|
/****************百度地图初始化完成****************/
|
|
371
|
381
|
//#endregion
|