mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Add default "Locator Overlay" layer
A layer that is by default visible at <z16 and can orient you with major roads, cities, borders, etc. Fixes #1301
This commit is contained in:
+18
-1
@@ -13,12 +13,29 @@
|
||||
"2",
|
||||
"3"
|
||||
],
|
||||
"default": "yes",
|
||||
"default": true,
|
||||
"sourcetag": "Bing",
|
||||
"logo": "bing_maps.png",
|
||||
"logo_url": "http://www.bing.com/maps",
|
||||
"terms_url": "http://opengeodata.org/microsoft-imagery-details"
|
||||
},
|
||||
{
|
||||
"name": "Locator Overlay",
|
||||
"template": "http://{t}.tiles.mapbox.com/v3/openstreetmap.map-btyhiati/{z}/{x}/{y}.png",
|
||||
"description": "Shows major features to help orient you.",
|
||||
"overlay": true,
|
||||
"default": true,
|
||||
"scaleExtent": [
|
||||
0,
|
||||
16
|
||||
],
|
||||
"subdomains": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
],
|
||||
"terms_url": "http://mapbox.com/tos/"
|
||||
},
|
||||
{
|
||||
"name": "MapBox Satellite",
|
||||
"template": "http://{t}.tiles.mapbox.com/v3/openstreetmap.map-4wvf9l0l/{z}/{x}/{y}.png",
|
||||
|
||||
@@ -196,6 +196,14 @@ iD.Background = function(context) {
|
||||
background.baseLayerSource(findSource(chosen) || findSource("Bing"));
|
||||
}
|
||||
|
||||
var locator = _.find(backgroundSources, function(d) {
|
||||
return d.overlay && d.default;
|
||||
});
|
||||
|
||||
if (locator) {
|
||||
background.toggleOverlayLayer(locator);
|
||||
}
|
||||
|
||||
var overlays = (q.overlays || '').split(',');
|
||||
overlays.forEach(function(overlay) {
|
||||
overlay = findSource(overlay);
|
||||
|
||||
@@ -49,6 +49,11 @@ iD.BackgroundSource = function(data) {
|
||||
});
|
||||
};
|
||||
|
||||
source.validZoom = function(z) {
|
||||
return source.scaleExtent[0] <= z &&
|
||||
(source.name !== 'Locator Overlay' || source.scaleExtent[1] > z);
|
||||
};
|
||||
|
||||
source.copyrightNotices = function() {};
|
||||
|
||||
return source;
|
||||
|
||||
@@ -65,7 +65,7 @@ iD.TileLayer = function() {
|
||||
function render(selection) {
|
||||
var requests = [];
|
||||
|
||||
if (tile.scaleExtent()[0] <= z) {
|
||||
if (source.validZoom(z)) {
|
||||
tile().forEach(function(d) {
|
||||
addSource(d);
|
||||
requests.push(d);
|
||||
|
||||
Reference in New Issue
Block a user