question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use ol-ext with nuxt?

See original GitHub issue

I’m trying to use vuelayers in a nuxt application. I have created a plugin like this:

import Vue from 'vue'
import VueLayers from 'vuelayers'

Vue.use(VueLayers)

Now, I want to use the strategy for loadingBBox

loadingStrategyFactory () {
        // VueLayers.olExt available only in UMD build
        // in ES build it should be imported explicitly from 'vuelayers/lib/ol-ext' 
        return loadingBBox
      },

But when I do this:

<script>
    import {loadingBBox} from 'vuelayers/lib/ol-ext'

    export default {

I get an error: Unexpected token export.

What’s the correct way?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ghettovoicecommented, Aug 8, 2019

Yes, you are right. In that case you see you load only part of the layer. Then when you move the map, this will trigger new load with the new view bbox and etc.

0reactions
niklashaacommented, Jun 29, 2021

My solution to using ol-ext was to use require in the method where I needed it:

    styleFuncFactory() {
      var olStyle = require("vuelayers/lib/ol-ext/style.js");
      return function __styleFuncFactory(feature) {
        const size = feature.getProperties().size;
        return [
          olStyle.createStyle({
            imageRadius: size,
            strokeWidth: 1.25,
            strokeColor: "#3399cc",
            fillColor: [255, 255, 255, 0.4],
          }),
        ];
      };
    },

Don`t know if this is best practice or not but it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation - Nuxt
Another way to get started with Nuxt is to use CodeSandbox which is a great way for quickly playing around with Nuxt and/or...
Read more >
Nuxt - The Intuitive Vue Framework
Build your next Vue.js application with confidence using Nuxt. An open source framework making web development simple and powerful.
Read more >
Content made easy for Vue developers · Nuxt Content
Take advantage of Nuxt 3 features: Vue 3, Auto-imports, Vite and Nitro server. File-based CMS. Write your content in Markdown, YML, CSV or...
Read more >
Configuration - Nuxt
You will still need to install the required loader if you need to use them. Style Extensions. You can omit the file extension...
Read more >
Commands and Deployment - Nuxt
Use it for Node.js hosting like Heroku, Digital Ocean, etc. target: static. nuxt dev - Launch the development server. nuxt ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found