Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/javascripts/config/layerlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import DeMvDepth from './layers/germany_mv_depth'
import ScubaDiving from './layers/scubaDiving'
import SeamarksDebug from './layers/seamarkDebug'
import Search from './layers/search'
import Marinetraffic from './layers/marinetraffic'
import GridWgs from './layers/grid_wgs'
import Download from './layers/downloadBundles'
import MarineProfile from './layers/marineProfile'
import ElevationProfile from './layers/elevationProfile'
import BingBase from './layers/bingBase'
import DebugTiles from './layers/tilesDebug'
import MarinetrafficImages from './layers/marinetraffic-imageLayer'

/**
for the old (2013) layers format see:
Expand Down Expand Up @@ -121,12 +121,6 @@ export const availibleOverlayLayers = [
urlIndex2016: 4,
visibleDefault: true
},
{
LayerConstructor: Marinetraffic,
id: 'overlay_marinetraffic',
urlIndex2016: 5,
visibleDefault: false
},
{
LayerConstructor: Download,
id: 'overlay_download',
Expand All @@ -139,6 +133,12 @@ export const availibleOverlayLayers = [
id: 'overlay_debug',
urlIndex2016: 10,
visibleDefault: false
},
{
LayerConstructor: MarinetrafficImages,
id: 'overlay_marinetraffic-imageLayer',
urlIndex2016: 11,
visibleDefault: false
}
]

Expand Down
43 changes: 43 additions & 0 deletions src/javascripts/config/layers/marinetraffic-imageLayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @license AGPL-3.0
* @author aAXEe (https://github.com/aAXEe)
*/
'use strict'

import ol from 'openlayers'
import ChartLayer from '../chartlayer'
import { layerTileLoadStateChange } from '../../store/actions'
import controlIds from '../../controls/ol3/controls'
import orderIds from '../layerOrderNumbers'

module.exports = function (context, options) {
// return the url to get the tile at [z, x, -y]
function tileUrlFunction (tileCoord) {
return ('https://tiles.marinetraffic.com/ais_helpers/shiptilesingle.aspx?output=png&sat=1&grouping=shiptype&tile_size=512&legends=1&zoom={z}&X={x}&Y={y}')
.replace('{z}', String(tileCoord[0] + 1))
.replace('{x}', String(tileCoord[1]))
.replace('{y}', String(-tileCoord[2] - 1))
}
var ATTRIBUTION = 'Ship data by <a href="https://marinetraffic.com/">MarineTraffic</a>'
let source = new ol.source.XYZ({
attributions: [new ol.Attribution({html: ATTRIBUTION})],
tileUrlFunction: tileUrlFunction,
crossOrigin: 'Anonymous',
tileSize: [512, 512]
})

source.on(['tileloadstart', 'tileloadend', 'tileloaderror'], function (ev) {
context.dispatch(layerTileLoadStateChange(options.id, ev))
})

var defaults = {
nameKey: 'layer-name-marinetraffic',
layer: new ol.layer.Tile({
source: source,
opacity: 0.7,
zIndex: orderIds.user_overlay
}),
additionalControls: [controlIds.scaleline_nautical, controlIds.attribution]
}
return new ChartLayer(context, Object.assign(defaults, options))
}