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

Docs: Google Maps example is not working #169

Closed
MickL opened this issue Jul 20, 2024 · 4 comments
Closed

Docs: Google Maps example is not working #169

MickL opened this issue Jul 20, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@MickL
Copy link
Contributor

MickL commented Jul 20, 2024

I was trying to use the example:

<script setup lang="ts">
const { $script } = useScriptGoogleMaps({
  apiKey: 'key'
})
$script.then(({ maps }) => {
  const map = new maps.Map(document.getElementById('map'), {
    center: { lat: -34.397, lng: 150.644 },
    zoom: 8
  })
})
</script>

But I get a type error in my IDE: Property Map does not exist on type typeof maps | Promise<typeof maps>

As well as an error in Vue/Nuxt: Uncaught (in promise) TypeError: maps.Map is not a constructor

@harlan-zw
Copy link
Collaborator

Hi, thanks for the issue. I'll need to update the docs but the types are a bit messed up. You can see how the <ScriptGoogleMaps> component handles that here: https://github.com/nuxt/scripts/blob/main/src/runtime/components/ScriptGoogleMaps.vue#L147

I would recommend using this component over using the script generally.

@MickL
Copy link
Contributor Author

MickL commented Jul 20, 2024

Hey thanks for the quick response!

I am using the component atm but I dont like that is is initially using a static map because the static map has a max width/height and therefor looks blurred on bigger screens and especially on high dpi screens. As there seems to be no option to disable it I was thinking I might integrate the map myself.

@harlan-zw harlan-zw added the documentation Improvements or additions to documentation label Jul 20, 2024
@MickL
Copy link
Contributor Author

MickL commented Jul 22, 2024

@harlan-zw Can we maybe have an option do disable the static map feature and immediately load the real map?

@harlan-zw
Copy link
Collaborator

Latest release has some improvements to maps, to answer your questions though:

If you'd like to disable the static map you can simply provide the placeholder slot.

<template>
  <ScriptGoogleMaps ...>
     <template #placeholder>
        <!-- my custom placeholder -->
     </template>
  </ScriptGoogleMaps>
</template>

If you'd like to load the maps as soon as possible you can set the trigger to immediate.

<template>
  <ScriptGoogleMaps trigger="immediate">
  </ScriptGoogleMaps>
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants