Hi Matti, Thanks for creating this useful addon! Everything works fine wit

Hi Matti,

Thanks for creating this useful addon! Everything works fine with the EPSG:4326 by default, but lately I bumped into an issue when defining a new projection (949900 from Mars 2000), so, according your guideline (v-ol3/v-ol3/src/test/java/org/vaadin/addon/vol3/demoandtestapp/Proj4jsMap.java at master · VOL3/v-ol3 · GitHub), I defined it as:

OLMapOptions opts=new OLMapOptions();
opts.defineProjection("IAU2000:49900","+proj=longlat +a=3396190 +b=3376200 +units=degrees +no_defs");
OLMap map = new OLMap(opts);

Later on, when setting the map projection on the view, I’ve put it as:

OLViewOptions options = new OLViewOptions();
//options.setInputProjection(Projections.EPSG4326);
options.setInputProjection("IAU2000:49900");
//options.setMapProjection(Projections.EPSG4326);
options.setMapProjection("IAU2000:49900");
OLView view = new OLView(options);

I’ve also added the notation @JavaScript(“proj4.js”), adding the file in the same directory than the caller java class (GisMap.java), although I’ve tested as well inside the VAADIN folder and directly calling to a url → @JavaScript(“https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js”)

The thing is, that when it comes to test it (with ?Debug mode), I’m retrieving this javascript error:

Error performing server to client RPC callscom.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'R' of undefined
   at Unknown.ukb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.PYb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.RYb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.eYb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.dYb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.KXb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.LXb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.tVb(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.eval(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.si(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.vi(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown.eval(esac.archive.psa.PsaWidgetSet-0.js)
   at Unknown._f(http://localhost:8080/psa-ui-map/VAADIN/vaadinPush.debug.js?v=7.7.9)
   at Unknown._invokeFunction(http://localhost:8080/psa-ui-map/VAADIN/vaadinPush.debug.js?v=7.7.9)
   at Unknown._invokeCallback(http://localhost:8080/psa-ui-map/VAADIN/vaadinPush.debug.js?v=7.7.9)
   at Unknown._websocket.onmessage(http://localhost:8080/psa-ui-map/VAADIN/vaadinPush.debug.js?v=7.7.9)

Do you know what it could be happening?

By the way, has the projection to be named as the one in geoserver? Because the IAU2000:49900 is gotten from http://spatialreference.org/ref/iau2000/49900/ (see proj4s format) and geoserver is giving it to me like EPSG:949900…

Many thanks for the support!

Cheers
Ruben

Hi Ruben!

  1. I would first use the inspector (chrome / firefox) to check whether it actually manages to load the javascript file (proj4.js).
  2. If the download is fine, I would recompile the widgetset using DETAILED mode to get a better stack trace to analyze. You can do that by adding <style>DETAILED</style> to your vaadin plugin configuration.

I don’t really have enough expertise on proj4.js to answer the last question regarding projection names and geoserver.

Cheers,
Matti

Thanks Matti for replying so quick!

It is a matter of paths on proj4.js. I used chrome inspector and indeed, the proj4.js was not found. However, it turns out that, in other branch, I was trying to test something with v-leaflet-proj4, and y tested by chance my v-ol3 test with the 949900 projection and…voila! it worked…so, somehow, it is getting some proj4.js file from those libraries associated to v-leaflet-proj4, specifically:

v-leaflet-proj4js-1.1-SNAPSHOT
v-leaflet-1.0.6
g-leaflet-1.0.11

The thing is that if removing those libraries, my v-ol3 does not work, It is a bit weird. So, what is the best way of calling the proj4.js library? (without including, obviously, the v-leaflet stuff, as it has nothing to do with v-ol3…). So far I’ve tested with:

@JavaScript("vaadin://proj4.js") //the proj4.js is under the VAADIN directory.
@JavaScript("proj4.js") //the proj4.js is in the same directory than the caller java class.
@JavaScript("https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js")

None worked…getting this error:

Proj4j not available, please include it before trying to define projections

Some suggestion? Thanks again!

Cheers,
Ruben

Hi Ruben,

The @javascript annotation loads the js-file from the classpath. My guess is that the proj4js is included in the leaflet jar-files and thus is found by the classloader.

I would recommend the @JavaScript(“proj4.js”) approach. Are you sure that the proj4j.js file you have is included to your build artifact and is in the same folder than the class where you have the annotation? Please verify that you can find the file inside your war file in the correct place. I have it in src/main/resources/org/vaadin/addon/vol3/demoandtestapp/ in my test project. Did you already check: [https://vaadin.com/api/framework/8.7.0/com/vaadin/annotations/JavaScript.html]
(http://)

Hi Matti,

Really sorry for this quite long time with no reply. I was focused on other things and now retaking this stuff. Unfortunately this does not work yet :(. I guess it is a problem regarding the widgetset build, I mean, where, supposedly, that file (proj4.js) should be allocated once the war is built? I’ve put it in these places but unsuccessfully:

  • within the /VAADIN/widgsets/[XXXWidgetSet/]

  • within the WEB-INF/classes/[src_structure]

  • within the /VAADIN/themes/[project]
    as a resource

Do I need to use the maven-resource-pluggin for this?

Moreover, If I use a url pointing out the proj4.js instead of physical file, it should work as well…but it doesn’t…I’m using vaadin 7.7.9 and V-OL3 1.3

Any new ideas??

Many thanks for your support
Regards,
Ruben
Thanks a lot!

Hi Ruben,

The absolute URL or WEB-INF-classes//proj4.js with the classloader approach should both work. For the latter one you probably need the resource-plugin. I don’t have any better ideas to be honest. You would need to see the request for the js-file and the response from chrome inspector. Those should give you the info what goes wrong. Especially for the case where you have an absolute url you are referencing.

Cheers,
Matti