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