rob-murray / os-leaflet Goto Github PK
View Code? Open in Web Editor NEWA Leafletjs TileLayer using Ordnance Survey OpenSpace web map service
Home Page: http://rob-murray.github.io/os-leaflet/
License: MIT License
A Leafletjs TileLayer using Ordnance Survey OpenSpace web map service
Home Page: http://rob-murray.github.io/os-leaflet/
License: MIT License
When applying for an OSOpenSpace API key it is associated with a project url. It appears from the example provided by OS that this should be included as the URL parameter in the WMS request as part of the authentication process. Currently this is hard-coded as URL: 'file:///'
which is allowed for testing purposes. It would be good to allow this to be overriden by a user-supplied value.
Leaflet 1.0 has been released (see https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md) so the way is clear to release os-leaflet 1.0.
When switching between multiple layers, if the OS layer is removed, the logo control remains. If the OS layer is added back then another logo control is added. You end up with multiple logos.
OpenSpace is no longer being developed. See https://www.ordnancesurvey.co.uk/forums/discussion/1010339/is-this-forum-active
It would be good to provide support for the replacement, called OS Map API.
See https://developer.ordnancesurvey.co.uk/os-maps-api-enterprise
It would be helpful if you could explain in what way this does not comply with the OS OpenSpace terms and conditions to help assess whether it can be made to comply. I note that the OS OpenSpace have demonstrated how to use an earlier version of this in a compliant fashion.
https://www.ordnancesurvey.co.uk/forums/discussion/1001864/using-leafletjs-with-openspace
upload to a cdn,
eg https://cdnjs.com/ (then 'request a lib')
thanks
andrew
Change the hardcoded OS tile url to '//openspace.ordnancesurvey.co.uk/osmapapi/ts', so it works with both http and https websites
Update the Attribution displayed on each map view. Possibly a link to the OS product page? so long as they dont change it too often :)
When using leaflet 1.0 beta, the error "TypeError: b is undefined" is thrown from line 1516 in leaflet-src.js. This getProjectedBounds function expects to see a bounds object in (I think) the CRS.projection.
From the Leaflet 1.0 beta changelog for 'TileLayer API improvements':
"Improved tile wrapping and bounding logic in TileLayer to work transparently and completely depent [sic] on the CRS used; removed the need for TileLayer hacks when using custom projections."
If you need more info or testing etc, I'm happy to help, but this is likely slightly deeper than I've been able to understand so far...
When minNativeZoom: 0 and a negative minZoom value are set on the tile layer, zooming out results in Uncaught Error: Attempted to load an infinite number of tiles
To reproduce set options as follows in OSOpenSpace.js:
options = L.extend({
crs: L.OSOpenSpace.CRS,
tileSize: 200,
minNativeZoom: 0,
maxNativeZoom: 0,
maxZoom: 0,
minZoom: -2
}, options);`
Here are two minimal tests to show the issue.
os-leaflet
https://5amc.cf/test/os.html
open street maps with the same options passed scales the zoom level 0 tiles as expected.
https://5amc.cf/test/l.html
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
minNativeZoom: 0,
maxNativeZoom: 0,
maxZoom: 0,
minZoom: -2
}).addTo(map);
Any ideas what might be the cause? I'm happy to investigate but would appreciate pointers if you have any.
The options parameter of the the factory method L.OSOpenSpace.tilelayer is ignored. It is passed as the third argument to L.TileLayer.WMS.prototype.initialize() which only takes 2 parameters.
The OSGB36 Proj4Leaflet implementation is not transforming from EPSG3857 to projected units correctly.
So, creating a LatLng in EPSG3857 creates a x,y in the wrong position, markers and overlays are not usable.
The web map service from Ordnance Survey returns various products or layers, the tile size in pixels of these can be 200px or 250px - at the moment this layer only supports the products that are at 200px.
We need to support the 250px tile sizes so that all products can be displayed.
Ordnance Survey product list: http://www.ordnancesurvey.co.uk/business-and-government/help-and-support/web-services/os-ondemand/configuring-wmts.html
Developers should not have to paste in the CRS implementation into their code; messy and error prone - move it out.
pseudo code example
var osMap = L.OS.Map.getOSMap(); //map with osgb36 projection
osMap.setView([x,y], 3);
miracles can happen!
well, maybe
https://osdatahub.os.uk/ now has a free tier
it just doesn't give an example of what the tile sets look like,
and if they include the 1:25 & 1:50 mapping
it supports osgb and web-mercator projections ... but not for all tile sets
Road | EPSG:27700 | Road_27700 | EPSG:27700
Road | EPSG:3857 | Road_3857 | EPSG:3857
Outdoor | EPSG:27700 | Outdoor_27700 | EPSG:27700
Outdoor | EPSG:3857 | Outdoor_3857 | EPSG:3857
Light | EPSG:27700 | Light_27700 | EPSG:27700
Light | EPSG:3857 | Light_3857 | EPSG:3857
Leisure | EPSG:27700 | Leisure_27700 | EPSG:27700
I've checked 'outdoor'. No footpaths.
The 'leisure' tile set is in osgb only, so i cant check it
This might help for use with leaflet
'https://osdatahubapi.os.uk/OSMapsAPI/wmts/v1?key=API_KEY&service=WMTS&request=GetTile&outputformat=image/png'
+ 'style=default&layer=Outdoor_3857&tileMatrixSet=EPSG:3857&tileMatrix={z}&tileRow={y}&tileCol={x}'
please could you see if its worth supporting...
andrew
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.