# up map search

This commit is contained in:
xianfuxing 2018-08-29 00:07:55 +08:00
parent 46e801346b
commit 71db09ce38
1 changed files with 23 additions and 4 deletions

View File

@ -29,6 +29,7 @@ const defaultEvents = {
export default { export default {
name: 'amap', name: 'amap',
data() { data() {
const self = this
return { return {
flag: false, flag: false,
defaultPositions: [ defaultPositions: [
@ -65,11 +66,29 @@ export default {
center: [], center: [],
markers: [], markers: [],
plugin: ['ToolBar', { plugin: ['ToolBar', {
pName: 'MapType', pName: 'Geolocation',
defaultType: 0,
events: { events: {
init(o) { init(o) {
console.log(o) // o
o.getCurrentPosition((status, result) => {
if (result && result.position) {
const lng = result.position.lng
const lat = result.position.lat
self.center = [lng, lat]
// self.loaded = true
self.$nextTick()
}
})
}
}
},
{
pName: 'Driving',
events: {
init(o) {
o.search(self.center, [113.276316, 23.112071], (status, result) => {
console.log(status, result)
})
} }
} }
}] }]
@ -97,7 +116,7 @@ export default {
marker.dragend = false marker.dragend = false
marker.events = defaultEvents marker.events = defaultEvents
this.markers.push(marker) this.markers.push(marker)
this.center = this.coordinate // this.center = this.coordinate
this.flag = true this.flag = true
}) })
} }