<!DOCTYPE html>
<html>
<head>
<title>i-Boating : Using leaflet to render a Nautical Chart over Open Street Maps</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"></script>
<!-- Nautical Mapping -->
<link rel='stylesheet' href='https://fishing-app.gpsnauticalcharts.com/i-boating-fishing-marine-navigation-sdk/5.5/blc-maps.css?rand=1695425337' />
<script src='https://fishing-app.gpsnauticalcharts.com/i-boating-fishing-marine-navigation-sdk/5.5/blc-maps.js?rand=1695425337'></script>
</head>
<body>
<div id="map"></div>
<!-- Leaflet Nautical Adapter -->
<script src="https://fishing-app.gpsnauticalcharts.com/i-boating-fishing-marine-navigation-sdk/5.5/leaflet-blc-adapter.js?rand=1695425337"></script>
<script>
var map = L.map('map').setView([37.8269, -122.3990], 13);
var osm = new L.TileLayer(
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
maxZoom:19,
attribution: 'Map data © OpenStreetMap contributors'
}
);
map.addLayer(osm);
L.marker([37.8269,-122.3990])
.bindPopup("Hello <b>Leaflet Nautical</b>!<br>Hello, World!")
.addTo(map)
.openPopup();
var latlngs = [[ 37.8269, -122.3990], [37.8211, -122.3396]];
var polyline = L.polyline(latlngs, {color: 'blue'});
polyline.addTo(map);
var latlngs = [ [37.8267, -122.417, ], [ 37.81, -122.413], [ 37.8183, -122.4429] ]
var polygon = L.polygon(latlngs, {color: 'red'});;
polygon.addTo(map);
var gl = L.blcGL({
blc_access_token:'YOUR_ACCESS_TOKEN_HERE',
blc_user_settings: {"depth":"m"},
blc_background_map: 'none'
}).addTo(map);
//move nautical map over OSM map by manipulating z-Indexes
var osmdiv = osm.getContainer();
var osmind = osmdiv.style.zIndex;
if((osmind !== undefined) && !isNaN(osmind)) {
var gldiv = gl.getContainer();
gldiv.style.zIndex = osmind+1;
}
</script>
</body>
</html>
New! i-Hunting Topo Maps now available -
iPhone / iPad Marine Navigation App and WMTS App are now available -
New! Macbook ChartPlotter, and Windows Marine Navigation App now available -