Compare commits

..

No commits in common. "a8e009ec709593c43ab408726ae23c976edf8f71" and "069e307b5ddaa1ca85a30f33f14c7395d0aca529" have entirely different histories.

1 changed files with 7 additions and 22 deletions

View File

@ -95,33 +95,18 @@ export default {
var geolocation = new BMap.Geolocation() var geolocation = new BMap.Geolocation()
const myGeo = new BMap.Geocoder() const myGeo = new BMap.Geocoder()
var $this = this var $this = this
map.enableScrollWheelZoom(true) // ,
map.addEventListener('zoomend', () => {
this.addPoint({
LATITUDE: $this.LATITUDE,
LONGITUDE: $this.LONGITUDE,
BMap,
map
})
})
// api // api
geolocation.getCurrentPosition(function(r) { geolocation.getCurrentPosition(function(r) {
myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), function(result) { myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), function(result) {
if (result) { if (result) {
$this.ISLOADingMap = false $this.ISLOADingMap = false
$this.$set($this, 'pointLngLat', { lng: result.point.lng, lat: result.point.lat }) $this.$set($this, 'pointLngLat', { lng: result.point.lng, lat: result.point.lat })
$this.setCenter({ BMap, map, zoom: 15 }) // map.enableScrollWheelZoom(true) // ,
$this.setCenter({ BMap, map })
} }
}) })
}) })
}, },
addPoint({ LATITUDE, LONGITUDE, BMap, map }) {
if (!LATITUDE) throw new Error('请传入经度')
if (!LONGITUDE) throw new Error('请传入纬度')
const point = new BMap.Point(LONGITUDE, LATITUDE)
const marker = new BMap.Marker(point) //
map.addOverlay(marker) //
},
// //
querySearch(queryString, cb) { querySearch(queryString, cb) {
var options = { var options = {
@ -154,7 +139,7 @@ export default {
this.LATITUDE = point.lat this.LATITUDE = point.lat
}, },
// //
setCenter({ BMap, map, zoom }) { setCenter({ BMap, map }) {
var lng = '' var lng = ''
var lat = '' var lat = ''
if (this.LONGITUDE === '' || this.LATITUDE === '') { if (this.LONGITUDE === '' || this.LATITUDE === '') {
@ -164,11 +149,11 @@ export default {
lng = this.LONGITUDE lng = this.LONGITUDE
lat = this.LATITUDE lat = this.LATITUDE
} }
map.panTo(new BMap.Point(lng, lat)) var point = new BMap.Point(lng, lat)
// const zoom = map.getZoom()
setTimeout(() => { setTimeout(() => {
map.setZoom(15) // map.centerAndZoom(point, zoom)
}, 300) // }, 0)
}, },
getClickInfo(e) { getClickInfo(e) {
this.LONGITUDE = e.point.lng this.LONGITUDE = e.point.lng