Commit 2ed67d83 authored by 黄奎's avatar 黄奎

地图修改

parent db16d7df
...@@ -60,24 +60,24 @@ export default { ...@@ -60,24 +60,24 @@ export default {
}, },
search() { search() {
var that = this var that = this
var map = new BMap.Map(`allmap_${that.id}${that.type}_${that.index}`) var map = new BMap.Map(`allmap_${that.id}${that.type}_${that.index}`, { enableMapClick: false })
var local = new BMap.LocalSearch(map, { // 智能搜索 var local = new BMap.LocalSearch(map, { // 智能搜索
onSearchComplete: function () { onSearchComplete: function () {
if (local.getResults() && local.getResults().getPoi(0) && local.getResults().getPoi(0).point) { if (local.getResults() && local.getResults().getPoi(0) && local.getResults().getPoi(0).point) {
that.userlocation = local.getResults().getPoi(0).point // 获取第一个智能搜索的结果 that.userlocation = local.getResults().getPoi(0).point // 获取第一个智能搜索的结果
that.point.lat = that.userlocation.lat that.point.lat = that.userlocation.lat
that.point.lng = that.userlocation.lng that.point.lng = that.userlocation.lng
// map.centerAndZoom(that.userlocation, 15) map.centerAndZoom(that.userlocation, 15)
map.addOverlay(new BMap.Marker(that.userlocation)) // 添加标注 map.addOverlay(new BMap.Marker(that.userlocation)) // 添加标注
} }
} }
}) })
local.search(that.city) local.search(that.city)
// map.addEventListener('click', function (e, target) { map.addEventListener('click', function (e, target) {
// // var point = new BMap.Point(e.point.lng, e.point.lat) // 创建点坐标,汉得公司的经纬度坐标 // var point = new BMap.Point(e.point.lng, e.point.lat) // 创建点坐标,汉得公司的经纬度坐标
// // map.centerAndZoom(point, 11) // map.centerAndZoom(point, 11)
// // that.point = e.point // that.point = e.point
// }) })
var gc = new BMap.Geocoder(); var gc = new BMap.Geocoder();
map.addEventListener('mousedown', function (type) { map.addEventListener('mousedown', function (type) {
var pt = type.point; var pt = type.point;
...@@ -91,7 +91,7 @@ export default { ...@@ -91,7 +91,7 @@ export default {
this.$nextTick(function () { this.$nextTick(function () {
var that = this var that = this
// 创建Map实例 // 创建Map实例
var map = new BMap.Map(`allmap_${that.id}${that.type}_${that.index}`) var map = new BMap.Map(`allmap_${that.id}${that.type}_${that.index}`, { enableMapClick: false })
// 获取当前位置 // 获取当前位置
var geolocation = new BMap.Geolocation(); var geolocation = new BMap.Geolocation();
...@@ -100,6 +100,7 @@ export default { ...@@ -100,6 +100,7 @@ export default {
var mk = new BMap.Marker(r.point); var mk = new BMap.Marker(r.point);
map.addOverlay(mk); map.addOverlay(mk);
map.panTo(r.point); map.panTo(r.point);
// map.mapClick = false
that.address_detail = addComp.province + "" + addComp.city + "" + addComp.district + "" + addComp.street + "" + addComp.streetNumber that.address_detail = addComp.province + "" + addComp.city + "" + addComp.district + "" + addComp.street + "" + addComp.streetNumber
that.point.lng = r.point.lng that.point.lng = r.point.lng
that.point.lat = r.point.lat that.point.lat = r.point.lat
...@@ -111,12 +112,11 @@ export default { ...@@ -111,12 +112,11 @@ export default {
} }
}); });
// 点击地图 // 点击地图
// map.addEventListener('click', function (e, target) { map.addEventListener('click', function (e, target) {
// // console.log('4545') // var point = new BMap.Point(e.point.lng, e.point.lat) // 创建点坐标,汉得公司的经纬度坐标
// // var point = new BMap.Point(e.point.lng, e.point.lat) // 创建点坐标,汉得公司的经纬度坐标 // map.centerAndZoom(point, 11)
// // map.centerAndZoom(point, 11) // that.point = e.point
// // that.point = e.point })
// })
var gc = new BMap.Geocoder(); var gc = new BMap.Geocoder();
map.addEventListener('mousedown', function (type) { map.addEventListener('mousedown', function (type) {
// map.centerAndZoom(type.point, 11) // map.centerAndZoom(type.point, 11)
...@@ -129,10 +129,10 @@ export default { ...@@ -129,10 +129,10 @@ export default {
}) })
// 初始化地图,设置中心点坐标, // 初始化地图,设置中心点坐标,
if (that.point.lat) { if (that.point.lat) {
// var point = new BMap.Point(that.point.lat, that.point.lng) // 创建点坐标 var point = new BMap.Point(that.point.lat, that.point.lng) // 创建点坐标
// map.centerAndZoom(point, 11) map.centerAndZoom(point, 11)
} else { } else {
// map.centerAndZoom(new BMap.Point(104.073652, 30.664369), 11); map.centerAndZoom(new BMap.Point(104.073652, 30.664369), 11);
} }
map.enableScrollWheelZoom() map.enableScrollWheelZoom()
if (that.Address) { if (that.Address) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment