OpenSeaMap Forum

New registrations / Neue Registrierungen

Please create and activate an account. Afterwards send an email to forum@openseamap.eu including a short message and your username to get write access to this forum. Thanks!

Bitte erstelle einen neuen Account und schalte ihn frei. Anschließend sende eine kurze Mail mit deinem Nutzernamen an forum@openseamap.eu um Schreibzugriff für dieses Forum zu bekommen. Danke!

Maintenance window / Wartungsfenster

This server undergoes periodic maintenance and will be unavailable for a few minutes between 00:00 UTC and 01:30 UTC at the first day of the month. New posts during that time could potentially be lost.

Dieser Server wird regelmäßig gewartet und ist deshalb für einige Minuten zwischen 00:00 UTC und 01:30 UTC am Monatsanfang nicht erreichbar. Es kann sein, dass in dieser Zeit erstellte Beiträge verloren gehen.

You are not logged in.

#1 2013-11-08 11:11:01

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

OpenSeaMap and OpenLayers 3

Hi,

does anybody know how to implement the seamark-layer in Openlayers 3?

In OpenLayers 2 it worked like this:
var layer_seamark = new OpenLayers.Layer.TMS ( "seamark", "http://tiles.openseamap.org/seamark/",
{ numZoomLevels: 18, type: 'png', getURL:getTileURL, isBaseLayer:false, displayOutsideMaxExtent:true });
map.addLayer(layer_seamark);

But in OpenLayers 3 there is no layer.tms anymore.

Anybody an idea??!?

Offline

#2 2013-11-19 12:04:56

dom
Member
Registered: 2012-09-06
Posts: 15

Re: OpenSeaMap and OpenLayers 3

Offline

#3 2013-11-19 16:26:56

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

Re: OpenSeaMap and OpenLayers 3

Doesn't work with me
Firefox - Firebug meldet mir:
SecurityError: The operation is insecure.
http://ol3js.org/en/master/build/ol.js
Line 258

No Seamarks are show and Error counter is running like hell in Firebug.

Last edited by SAILBOOK (2013-11-20 12:07:01)

Offline

#4 2013-11-20 11:11:37

dom
Member
Registered: 2012-09-06
Posts: 15

Re: OpenSeaMap and OpenLayers 3

In my opinion you should avoid referencing to external scripts in your application. Several problems can occur:

* If the remote host is not available, your application won't work.
* If the remote version changes, your application may crash.
* People with activated security plugins like 'NoScript' have to unblock such external references as well.

I downloaded the last version and copied both files (ol.css and ol.js) into the corresponding
directory. Works with Firefox and Chrome.

Offline

#5 2013-11-20 13:47:38

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

Re: OpenSeaMap and OpenLayers 3

Could you send me an example? I can't get it working. If I choose the local directory for ol.js after having put it there, I get the same error.

Firebug only calls the error, when using your statement:
new ol.layer.Tile({
       source: new ol.source.XYZ({
       url: 'http://t1.openseamap.org/seamark/{z}/{x}/{y}.png'
   })
})

to add the seamark layer!

Last edited by SAILBOOK (2013-11-20 14:06:33)

Offline

#6 2013-11-27 14:32:26

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

Re: OpenSeaMap and OpenLayers 3

Does your way still work, if you add this to your code:
new ol.layer.Tile({
  source: new ol.source.XYZ({
     url: 'http://t1.openseamap.org/seamark/{z}/{x}/{y}.png',
     crossOrigin: 'null'
  })
})

This solves my issue, but I still can't see the seamarks!

Even JSFiddle doesn't seem to get it working http://jsfiddle.net/J2KBC/

Last edited by SAILBOOK (2013-11-27 14:42:21)

Offline

#7 2013-11-28 11:29:45

dom
Member
Registered: 2012-09-06
Posts: 15

Re: OpenSeaMap and OpenLayers 3

I used 't1.openseamap.org' instead of 'tiles.openseamap.org' (like described in the wiki http://wiki.openseamap.org/wiki/De:Open … nLayers_3) and commented out 'crossOrigin'.

http://jsfiddle.net/jt3s8/

Tested on Firefox and Chrome. Does this run on your machine?

Offline

#8 2013-11-28 12:33:57

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

Re: OpenSeaMap and OpenLayers 3

It makes no difference for me, if I user t1 or tiles or crossOrigin or not.

I checked it on every browser on 4 different pcs and networks.

It works in Safari always. It works in Chrome Mobile! (With crossOrigin, without crossOrigin, with t1 or tiles)
Opera, Chrome, Firefox, IE don't show it. Firebug calls Insecure Errors, if I am missing the crossOrigin property.
So I would say add "crossOrigin" since it prevents errors and works just as well, if it works at all.

From what I see it depends on the Javascript Engine being used. Chrome and Firefox changed their engine while updating the browsers.
Which Firefox and Chrome browser do you use?

This is driving me nuts...

Offline

#9 2013-11-28 16:14:31

dom
Member
Registered: 2012-09-06
Posts: 15

Re: OpenSeaMap and OpenLayers 3

I changed the CORS headers on server side.

Please try again. Does it work?

Offline

#10 2013-11-28 16:37:08

SAILBOOK
Member
Registered: 2013-11-08
Posts: 6

Re: OpenSeaMap and OpenLayers 3

Yes... using t1 it finally works!!!
But crossOrigin: 'null' is necessary!

EDIT:
And they say we should use: Canvas
https://github.com/openlayers/ol3/issues/1326

Last edited by SAILBOOK (2013-11-29 07:46:14)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman