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

Using this in Vue JS #319

Open
bradleyw92 opened this issue Aug 5, 2021 · 2 comments
Open

Using this in Vue JS #319

bradleyw92 opened this issue Aug 5, 2021 · 2 comments

Comments

@bradleyw92
Copy link

bradleyw92 commented Aug 5, 2021

I have a Vue JS component that loads data through an API which includes latitude and longitude.

I've successfully loaded the latitude and longitude data on the component so all I would need to do is include it on the below function inside the center option.

I was hoping I'd be able to embed the following on a Vue component:

{{ craft.maps.img({
                        width: 1400,
                        height: 1400,
                        center: 'Maidstone, UK',
                    })
}}

But comes up with the following error:

Property or method "craft" is not defined on the instance but referenced during render.

Please can you advise on how I would include one of the maps options inside a Vue component?

@alexjcollins
Copy link
Member

Depends on how you have things set up but could you set craft.maps.img() inside twig and then pass the URL it creates to your Vue component?

e.g.

{% set mapUrl = craft.maps.img({
    width: 1400,
    height: 1400,
    center: 'Maidstone, UK',
}) %}

Then:

<map map-url="{{ mapUrl }}"></map>

@bradleyw92
Copy link
Author

bradleyw92 commented Aug 5, 2021 via email

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

No branches or pull requests

2 participants