| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <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>
|