1

Topic: openlayer problem

Good day, i have noticed in a page using Report/Distribution Map1, the layer from GeoServer is not working, even if i see the image layer on firebug... I get this error in console:

Uncaught TypeError: OpenLayers.Protocol.Script is not a constructor
    at initialize.activate (jquery.indiciaMapPanel.js?oqi4mi:1065)
    at HTMLDivElement.<anonymous> (jquery.indiciaMapPanel.js?oqi4mi:2321)
    at Function.each (jquery.min.js?v=1.10.2:4)
    at $.fn.init.each (jquery.min.js?v=1.10.2:4)
    at $.fn.init.$.fn.indiciaMapPanel (jquery.indiciaMapPanel.js?oqi4mi:1687)
    at 52:114
    at Function.<anonymous> (52:123)
    at Function.each (jquery.min.js?v=1.10.2:4)
    at window.onload (52:122)

and the "bad" line is this:

this.protocol = new OpenLayers.Protocol.Script({
    url: wmsUrl,
    callback: this.onResponse,
    scope: this
});

I tried to change that line from "new OpenLayers.Protocol.Script" to "new OpenLayers.Protocol", i don't get error but i continue not to see the layer... The problem is suppose is after the update to indicia iform 1.1.0. Any idea to resolve the problem with this module page? Thanks

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

2 (edited by Andrew van Breda 11-09-2017 20:06:46)

Re: openlayer problem

Hi Carlo,

My name is Andrew van Breda (brother of John van Breda). I have been developing for Indicia for 5 years now, although admittedly not dealing too much with GeoServer layers directly. As there haven’t been any replies yet I thought I might at least throw some ideas in your direction.

My first port of call would be to try changing the “Type of OpenLayers.js file used“ option at the bottom of the iForm settings area.
This can be found be going to the Configuration menu, “Settings” in the IFORM section and it is at the bottom of that page.
Does that help? I would do this with an unaltered version of the code.
It might also be worth trying a later development version of the jQuery.indiciamappanel.js  file to see if that might fix the issue as a temporary test, or perhaps even revert to the previous version of that particular file as a test.
Although if I were to guess I don’t think it is as simple as a code bug. I think it isn’t finding OpenLayers properly

Note also that you will probably need to clear the iForm cache or Drupal cache after any of the above actions

Hope this helps

3

Re: openlayer problem

Hi Andrew, nice to meet you. I have tried to change the type but nothing changed... To solve the problem, in these weeks, i have done an html page using a standalone OpenLayers.js to call the wms from GeoServer...
A question: is there a way to inquire GeoServer from OpenLayers to get info about occurrence clicked on a point?

Thanks

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

4

Re: openlayer problem

Hi Carlo,

I have certainly retrieved information from points after clicking, but only using Indicia’s map panels.

I'm afraid I haven’t dealt much with Geoserver directly, I spend more of my time writing custom data entry submission code, SQL reports (often for maps) and coding warehouse modules such as BRC’s species alerts.

It might still be worth getting your OpenLayers problem with indiciamappanel fixed, then you can have access to all of Indicia’s features

So I will explain how I have worked with a clickable report layer in Indicia in the past, if there is anything useful for you then great. Failing that, you might get a good idea of Indicia’s other capabilities.

So for the map I have specified something like this in the Form Structure for the indicia page

[map]
@customClickFn=function_name
@clickableLayersOutputMode=customFunction
@clickableLayers=["indiciaData.reportlayer"]
@dataSource=report_path

In this case, the function “function_name” is a function to be performed when the map feature is clicked and is specified in a node.<node_id>.js file in this case in Drupal.

This function accepts a features parameter like this
function function_name(features) {

I have then been able to refer database fields for the clicked feature in that function using the following syntax where feature[0] is the clicked one.

features[0].attributes.id
features[0].attributes.entered_sref

So “entered_sref” is a field output by my report, but I would think would be a database field like public_entered_sref if a source is a view like cache_occurrences

So you can do things like

var r = confirm("Would you like to assign square "+features[0].attributes.entered_sref+ " to yourself?");

Sorry not to have been of much more use, I hope there is at least something vaguely useful in there.
I tend to get rusty on things I am not doing everyday

5

Re: openlayer problem

Hi Andrew,
i was trying again today to change OpenLayer version but i don't see any errors (only with custom i see)

You can see the problem here with the layer not showing, maybe you notice some JS not compatible...

http://www.naturaesocialmapping.it/node/52

The first map in this page is an iframe using a standalone OpenLayer.js calling the WMS on GeoServer.
The second is using Indicia with OpenLayer custom

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

6

Re: openlayer problem

Hi,

Yes it good to have a look at the page.

I don't use pure 1.1.0 on my own machine normally as I have develop code, so I tried the download here (using the link that contains all the submodules),

github.com/Indicia-Team/drupal-7-module-iform/releases/tag/v1.1.0

I then did a difference compare with your jqueryindiciamappanel.js code showing in my debugger and they appear to be quite different, in fact I think your one is missing quite a lot of the newer code. There are definitely lines of code I remember coding ages ago that are missing from your file.

I am now wondering whether some of the files in your upgrade package were missing so you have a corrupted install perhaps. It is certainly something worth pursuing

Could you let me know where you got your download from and I will take a look.

Thanks

7

Re: openlayer problem

Hi Andrew,
i got from here some months ago, when i updated the server where runs Indicia:

https://github.com/Indicia-Team/drupal- … tag/v1.1.0

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

8

Re: openlayer problem

Hi,

Ok, so that is just the same link I used I think.

So the next question is why does you jQuery.indiciamappanel.js file differ on your site. As it was updated ages ago it is unlikely to be a caching.

It probably isn't necessary to send me the whole file.

Are you able to locate the file on your server and tell me how many lines of code it has? (so I be sure what my browser is showing me is correct)
Then I will know for sure if there is something wrong there

Thanks

9

Re: openlayer problem

I would actually simply try the update again, make sure you use the link on that page that includes all the submodules.

You could try a comparison (either file difference, or visually) of the jQuery.indiciamappanel.js file with what is in that package with what is on the disc.
I suspect they are different.
That file is in the media/js folder

If they are different I would definitely go ahead and try and re-apply the update

10

Re: openlayer problem

Hi to everyone,
sorry for long delay in reply. I have checked the file /sites/all/modules/iform/media/js/jquery.indiciaMapPanel.js on server and the file from Release 1.21.0 (the lastest) and from the releasei used (1.10.0) are the same. I have checked also 1.15.0 and is same. To be sure, i have uploaded the file from the latest version but i continue not to see the layer...

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

11

Re: openlayer problem

Hi Carlo

The 'released' code can actually be quite out of date. Better to use the most recently tagged version.
You can obtain the IForm module plus its libraries from
https://github.com/Indicia-Team/drupal- … iform/tags
https://github.com/Indicia-Team/client_helpers/tags
https://github.com/Indicia-Team/media/tags

While updating may not solve your problem at least you will be working from the same code base that would be the basis of any bug fixes.

Jim Bacon.

12

Re: openlayer problem

Hi Carlo,

Looking at your http://www.naturaesocialmapping.it/node/52 you will see there is a JavaScript error "TypeError: OpenLayers.Protocol.Script is not a constructor" as described in your original post.

That is because Protocol.Script is not included in the OpenLayers.js you are using.

As Andrew suggested earlier, you need to switch to a different version of the OpenLayers library. Ensure the Indicia Openlayers module is enabled and in the Configuration > IForm > Settings change the Type of OpenLayers.js file used to Official Minimised Version.

You said you tried that already but the layer still didn't show. Nonetheless, it is a pre-requisite that you must change to the Official Minimised Version before any other fault can be identified and fixed.

Jim.

13

Re: openlayer problem

Hi Jim,
i have switched again to the Official Minimised Version...

Carlo Politi - Software Engineer
QuestIT s.r.l.
Home page: www.quest-it.com
E-Mail: politi@quest-it.com - Skype: carlo.politi.questit

14

Re: openlayer problem

Hi Carlo,

That's better. No JavaScript errors now. Using browser debugging I see the network request for the wms layer

http://postgres.comune.grosseto.it:8080/geoserver/wms?LAYERS=NaturaeSocialMapping:detail_occurrences&TRANSPARENT=TRUE&CQL_FILTER=website_id=2 AND taxon_meaning_id=6134&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image/png&SRS=EPSG:3857&BBOX=-179807.06812719,4191869.6764499,2990189.3684744,6393256.0907563&WIDTH=1296&HEIGHT=900

which returns a map that looks correct.

This is added to the page and shows up in the html

<div id="OpenLayers_Layer_WMS_2" dir="ltr" class="olLayerDiv olLayerGridSingleTile" style="position: absolute;width: 100%;height: 100%;z-index: 330;">
  <img class="olTileImage" src="http://postgres.comune.grosseto.it:8080/geoserver/wms?LAYERS=..." 
    style="visibility: inherit; opacity: 1; position: absolute; left: -216px; top: -150px; width: 1296px; height: 900px;">
</div>

The image is not appearing because its height is zero. If you can work out why the inline style, height: 900px,  is being ignored then you may have a solution.

Given there is a problem with dimensions, one thing to check is the width and height configuration. Try alternatives e.g. Width: 300, Height: 300. I don't suppose it is this simple.

I'm wondering if OpenLayers is setting the image height to 0. If you switch to the debug version of OpenLayers and put breakpoints in places where style.height is changed you might manage to trap something.

Here is one that works... http://www.mothnight.info/node/8

Regards,
Jim Bacon.

15

Re: openlayer problem

Doh, silly me.
I should have seen it's your css rule that is causing the problem.

img {
  max-height: 100%;
}

You need to stop this targeting the map.

Jim Bacon.