[SOLVED] Widget control of OpenLayers5 JavaScript About replacing?

Answered
0
0

OpenLayers 5.3 JavaScirpt (WebGisOlTestHtml.zip)
Convert a program created in to a widget control
(WebOl53TestPg.zip) I moved the program
Error (Widget_Err.jpg) is displayed at the mouse event
Will be
Please tell me the cause.

  • You must to post comments
Best Answer
0
0

I looked into this in more details and it turns out it’s your javascript code that has the bug not IE.

In the IFrame sample you assigned “var map” in the <script> tag and refer to it in the local function and event handler. This is why it works.

In the Widget sample:

  • The first error is “this.addListener(‘pointermove’)” instead of “map.on(‘pointermove’). The first attaches to “this” (which is a Wisej object” and receives a Wisej event object. The second attaches to the OL5 widget and receives an OL5 event object. But in the Wisej handler you refer to the OL5 properties…
  • Once you fix the handler, the second problem is the context. OL5 handlers don’t restore the context (Wisej does), therefore “this” is window in javascript.
  • Then you used “this.map” instead of a local “var map”. In javascript “this” is not the current object in a callback handler, it’s the execution context wich is window by default. The local function “displayFeatureInfo” is called from the handler callback, therefore the context is lost and “this.map” is undefined.

The fix is simply to save a local “var map” referring to the map and use it in the closure local function.

See attached script.

 

Attachment
  • You must to post comments
0
0
Levie (ITG)
Now works properly.
Thank you.
  • You must to post comments
0
0
I asked for an answer that it was an OpenLayers problem,
Same OpenLayers in Wisej’s iFramePanel Control
If you embed the program of the program, it works
Why not?
  • You must to post comments
0
0

Takao,

thanks for providing more information.
However the code creating the problems on IE 11 that you showed
comes from OpenLayers, not Wisej.
So it´s not a Wisej problem and you should rather contact the makers of OpenLayers
to get support for that specific issue.

Best regards
Frank

  • You must to post comments
0
0

The browser that causes the problem is IE11.
With other browsers (FireFox, Chrome, Edge)
No errors occur but normal operation is also
I do not.
Where errors occur is in the InitScript
Line 81 “var pixel = this.map.getEventPixel (evt.originalEvent);”
Will cause an error.
If it works properly, the mouse will move
Filled in red. (SampleHtml.jpg)

Thank you.

Attachment
  • You must to post comments
0
0

Hi Takao,

I have tried to reproduce the problem but I get no error.
Can you please tell a few more details ?
In which browser and on which action does the error occur ?

Thanks in advance.

Best regards
Frank

  • Takao Watanabe
    I added the information I asked.
  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.