ghettovoice / vuelayers

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

Projections failing in v12.x #515

Closed bmcalees closed 2 years ago

bmcalees commented 2 years ago

I'm just getting around to updating to v12.x and getting the following warning/errors:

image

I'm assuming the warnings are tied to the errors but not sure.

Previously, we passed the 'projection name' to the vl-map and vl-view components and this seemed to work fine. Has this changed?

Here is an example of the projection I'm trying to use. Previously it was added via the 'addProj' import from VueLayers but this has been changed to use OL now.

import { addProjection as addProj, get as getProj } from 'ol/proj'; import Projection from 'ol/proj/Projection'; const projection = new Projection({ code: this.projectionName, units: 'pixels', extent: this.extent, }); addProj(projection);

Lastly, here is how the projection is being sent to VueLayers:

image

ghettovoice commented 2 years ago

Hello @bmcalees , very often after upgrade to v0.12 you may have now 2 versions of ol package inside node_modules, v5 used with vuelayers v0.11 and v6 installed with vuelayers v0.12. Probably because you manually installed ol@v4 before and have it's amoung your app dependencies. Try to drop any ol package and re-install vuelayers v0.12.

bmcalees commented 2 years ago

Hi @ghettovoice,

I triple checked and only one version of ol in node_modules. I've also deleted node_modules and re-installed.

The error seems to be coming from the inability to find the destination projection. Notice in the image below that destination = CYTO-241607821 but destinationProjection = null.

image

In my original question I show how the projection is being created and added. Any idea why this isn't working?

bmcalees commented 2 years ago

Found my issue. I was adding my projection to my local instance of ol and not the VueLayers instance.

In the prior version of VueLayers these ol functions were exposed like so:

import { addProj, createProj, getProj } from 'vuelayers/lib/ol-ext';

The solution was to change it to this:

import { addProjection as addProj } from 'vuelayers/node_modules/ol/proj';