simplemap icon indicating copy to clipboard operation
simplemap copied to clipboard

Using this in Vue JS

Open bradleyw92 opened this issue 3 years ago • 2 comments

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?

bradleyw92 avatar Aug 05 '21 10:08 bradleyw92

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>

alexjcollins avatar Aug 05 '21 11:08 alexjcollins

So that’s what I’ve got currently but problem I have is inside the Vue the component is my two values for lat and long which are coming from an Axios request so it’s a case of seeing how we pass those values back to the main twig file inside the centre option.

On Thu, 5 Aug 2021 at 12:42, Alex Collins @.***> wrote:

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:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ethercreative/simplemap/issues/319#issuecomment-893391601, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANIBWLEXTSGHWE2YW5UQRQ3T3J2MBANCNFSM5BTR7RSQ .

bradleyw92 avatar Aug 05 '21 11:08 bradleyw92