ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
681 stars 230 forks source link

How to use the custom ol/source/TileImage? #385

Closed vvizden closed 3 years ago

vvizden commented 3 years ago

Hi,

The TileSuperMapRest extends ol/source/TileImage in the code snippet below. How can i code when using vuelayers?

Thank you!

var layer = new ol.layer.Tile({
    source: new TileSuperMapRest({
        url: url,
        wrapX: true
    }),
    projection: 'EPSG:3857'
});
ghettovoice commented 3 years ago

Hello @vvizden , you can wrap TileSuperMapRest into Vue component (similar to VueLayers sources) or just add source in runtime.

  1. Wrap into the component it depends on which VueLayers version do you using:

Those mixins provides basic methods, props, watchers.

  1. Append your custom source in runtime
<vl-layer-tile ref="layer" @created="layerCreated" />

<script>
export default {
  methods: {
    layerCreated (vm) {
      vm.$layer.setSource(new TileSuperMapRest({
        url: url,
        wrapX: true
      }))
    },
  },
}
</script>