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 21: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