/*var crs = new L.Proj.CRS(
'EPSG:27700',
'+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs',
{
resolutions: [1600,800,400,200,100,50,25,10,5,2.5,1,0.5,0.25,0.125,0.0625]
}
);*/
// Setup the EPSG:27700 (British National Grid) projection.
const crsnew = new L.Proj.CRS('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs', {
resolutions: [ 896.0, 448.0, 224.0, 112.0, 56.0, 28.0, 14.0, 7.0, 3.5, 1.75 ],
origin: [ 100000000, 100000000 ]
});
//const map = L.map('map').setView([82.35, -168.4], 19);
//good for uk !!!const map = L.map('map').setView([83.9, -174.5], 5);
//const map = L.map('map').setView([53.199375, -1.4341342], 19);
//const map = L.map('map').setView([53.199478, -1.4347414], 15);
const cartoSatellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: '© ESRI',
subdomains: 'abcd',
maxZoom: 19,
crs: crsnew
});
const cartoMappingGB = L.tileLayer('https://mappinggb.com/xyztiles?x={x}&y={y}&z={z}', {
attribution: '© MappingGB',
subdomains: 'abcd',
maxZoom: 19,
crs: crsnew
});
const cartoOpenStreetMap = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap',
subdomains: 'abcd',
maxZoom: 19,
crs: crsnew
});
var map = L.map('map', {
center: [51.494, 0.042],
zoom: 13,
//layers: [cartoMappingGB, cartoSatellite, cartoOpenStreetMap]
layers: [cartoOpenStreetMap, cartoSatellite, cartoMappingGB]
});
//const map = L.map('map').setView([70, -168.4], 10);
//const map = L.map('map').setView([-100, -100], 10);
map.on('click', function(e) {
//alert("Lat, Lon : " + e.latlng.lat + ", " + e.latlng.lng);
//alert(transformCoords([e.latlng.lng, e.latlng.lat]));
url = getTileURL(e.latlng.lat, e.latlng.lng, map.getZoom())
//console.log(url);
//alert(url);
});
map.addControl(
L.control.locate({
locateOptions: {
enableHighAccuracy: true
}
})
);
var baseMaps = { "Satellite": cartoSatellite, "OpenStreetMap": cartoOpenStreetMap, "MappingGB": cartoMappingGB };
L.control.layers(baseMaps).addTo(map);
function getTileURL(lat, lon, zoom)
{
var xtile = parseInt(Math.floor( (lon + 180) / 360 * (1<