Use live bound object for imagery array, remove context.imagery() accessor

Also update documentation, closes #3359
This commit is contained in:
Bryan Housel
2016-11-14 11:15:03 -05:00
parent 9c8037ca4e
commit 93d50b4e87
12 changed files with 97 additions and 42 deletions
+3 -9
View File
@@ -259,13 +259,6 @@ export function coreContext() {
};
/* Imagery */
context.imagery = function(_) {
background.load(_);
return context;
};
/* Container */
var container, embed;
context.container = function(_) {
@@ -347,7 +340,7 @@ export function coreContext() {
context.reset = context.flush = function() {
context.debouncedSave.cancel();
_.each(services, function(service) {
if (typeof service.reset === 'function') {
if (service && typeof service.reset === 'function') {
service.reset(context);
}
});
@@ -407,10 +400,11 @@ export function coreContext() {
context.zoomOutFurther = map.zoomOutFurther;
context.redrawEnable = map.redrawEnable;
background.init();
presets = presetInit();
_.each(services, function(service) {
if (typeof service.init === 'function') {
if (service && typeof service.init === 'function') {
service.init(context);
}
});
+7 -5
View File
@@ -1,10 +1,11 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { utilRebind } from '../util/rebind';
import { data } from '../../data/index';
import { geoExtent, geoMetersToOffset, geoOffsetToMeters} from '../geo/index';
import { utilQsString, utilStringQs } from '../util/index';
import { rendererBackgroundSource } from './background_source';
import { rendererTileLayer } from './tile_layer';
import { utilQsString, utilStringQs } from '../util/index';
import { utilRebind } from '../util/rebind';
export function rendererBackground(context) {
@@ -191,7 +192,7 @@ export function rendererBackground(context) {
};
background.load = function(imagery) {
background.init = function() {
function parseMap(qmap) {
if (!qmap) return false;
var args = qmap.split('/').map(Number);
@@ -199,12 +200,13 @@ export function rendererBackground(context) {
return geoExtent([args[1], args[2]]);
}
var q = utilStringQs(window.location.hash.substring(1)),
var dataImagery = data.imagery || [],
q = utilStringQs(window.location.hash.substring(1)),
chosen = q.background || q.layer,
extent = parseMap(q.map),
best;
backgroundSources = imagery.map(function(source) {
backgroundSources = dataImagery.map(function(source) {
if (source.type === 'bing') {
return rendererBackgroundSource.Bing(source, dispatch);
} else {
+3 -2
View File
@@ -1,9 +1,9 @@
import * as d3 from 'd3';
import { geoPolygonIntersectsPolygon } from '../geo/index';
import {
data,
dataImperial,
dataDriveLeft,
dataImagery
dataDriveLeft
} from '../../data/index';
@@ -83,6 +83,7 @@ export function svgDebug(projection, context) {
var extent = context.map().extent(),
dataImagery = data.imagery || [],
availableImagery = showsImagery && multipolygons(dataImagery.filter(function(source) {
if (!source.polygon) return false;
return source.polygon.some(function(polygon) {