Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.h is not a function ? #374

Open
slpzc opened this issue Mar 11, 2022 · 2 comments
Open

t.h is not a function ? #374

slpzc opened this issue Mar 11, 2022 · 2 comments
Labels

Comments

@slpzc
Copy link

slpzc commented Mar 11, 2022

<template>
  <div id="map">
    <yandexMap
      ref="myMap"
      :coords="DEFAULT_COORDS"
      class="full-width"
      :zoom="MAP_ZOOM"
      :scroll-zoom="false"
      @map-was-initialized="ready"
    >
    </yandexMap>
  </div>
</template>

<script>
import { loadYmap } from 'vue-yandex-maps'

export default {
  name: 'indexYandexMap',
  data: () => ({
    API_KEY: 'мой ключ',
    DEFAULT_COORDS: [58.812924, 36.500804],
    MAP_ZOOM: 5,
    needToLoad: false
  }),
  created () {
    this.$axios
      .get(`https://api-maps.yandex.ru/2.1?lang=en_RU&apikey=${this.API_KEY}`)
      .then(() => {
        this.needToLoad = true
      })
      .catch(() => {
        this.needToLoad = false
      })
  },
  async mounted () {
    await loadYmap({
      apiKey: this.API_KEY
    })
  },
  methods: {
    ready () {
      const map = this.$refs.myMap.myMap
      map.controls.remove('rulerControl')
      map.controls.remove('geolocationControl')
      map.controls.remove('trafficControl')
      map.controls.remove('typeSelector')
      map.controls.remove('fullscreenControl')
      map.controls.remove('searchControl')
    }
  }
}
</script>

<style scoped>

</style>

В итоге получаю t.h is not a function. Как решать?

@artemryskal
Copy link

Посмею предположить, что вы должны использовать аргумент метода "ready", вместо this.$refs

@alex-wdmg
Copy link

alex-wdmg commented Jun 8, 2022

      methods: {
                ready (map) {
                    //const map = this.$refs.myMap.myMap
                    map.controls.remove('rulerControl');
                    map.controls.remove('geolocationControl');
                    map.controls.remove('trafficControl');
                    map.controls.remove('typeSelector');
                    map.controls.remove('fullscreenControl');
                    map.controls.remove('searchControl');
                }
      }

@daniluk4000 daniluk4000 added the bug label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants