You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
60 lines
1.2 KiB
3 months ago
|
<script>
|
||
|
import commonMixin from '../base/mixins/common.js'
|
||
|
import bindEvents from '../base/bindEvent.js'
|
||
|
import {createIcon, createSize} from '../base/factory.js'
|
||
|
|
||
|
export default {
|
||
|
name: 'bm-geolocation',
|
||
|
render () {},
|
||
|
mixins: [commonMixin('control')],
|
||
|
props: {
|
||
|
anchor: {
|
||
|
type: String
|
||
|
},
|
||
|
offset: {
|
||
|
type: Object
|
||
|
},
|
||
|
showAddressBar: {
|
||
|
type: Boolean
|
||
|
},
|
||
|
autoLocation: {
|
||
|
type: Boolean
|
||
|
},
|
||
|
locationIcon: {
|
||
|
type: Object
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
anchor () {
|
||
|
this.reload()
|
||
|
},
|
||
|
offset () {
|
||
|
this.reload()
|
||
|
},
|
||
|
showAddressBar () {
|
||
|
this.reload()
|
||
|
},
|
||
|
autoLocation () {
|
||
|
this.reload()
|
||
|
},
|
||
|
locationIcon () {
|
||
|
this.reload()
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
load () {
|
||
|
const {BMap, map, anchor, showAddressBar, autoLocation, locationIcon, offset} = this
|
||
|
this.originInstance = new BMap.GeolocationControl({
|
||
|
anchor: global[anchor],
|
||
|
showAddressBar,
|
||
|
enableAutoLocation: autoLocation,
|
||
|
offset: offset && createSize(BMap, offset),
|
||
|
locationIcon: locationIcon && createIcon(BMap, locationIcon)
|
||
|
})
|
||
|
bindEvents.call(this, this.originInstance)
|
||
|
map.addControl(this.originInstance)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|