diff --git a/modules/core/context.js b/modules/core/context.js index 4d758066e..31dbe7deb 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -119,7 +119,7 @@ export function coreContext() { return context; }; - context.loadTiles = utilCallWhenIdle(function(projection, dimensions, callback) { + context.loadTiles = utilCallWhenIdle(function(projection, callback) { var cid; function done(err, result) { if (connection.getConnectionId() !== cid) { @@ -131,11 +131,11 @@ export function coreContext() { } if (connection && context.editable()) { cid = connection.getConnectionId(); - connection.loadTiles(projection, dimensions, done); + connection.loadTiles(projection, done); } }); - context.loadEntity = function(entityId, callback) { + context.loadEntity = function(entityID, callback) { var cid; function done(err, result) { if (connection.getConnectionId() !== cid) { @@ -147,24 +147,24 @@ export function coreContext() { } if (connection) { cid = connection.getConnectionId(); - connection.loadEntity(entityId, done); + connection.loadEntity(entityID, done); } }; - context.zoomToEntity = function(entityId, zoomTo) { + context.zoomToEntity = function(entityID, zoomTo) { if (zoomTo !== false) { - this.loadEntity(entityId, function(err, result) { + this.loadEntity(entityID, function(err, result) { if (err) return; - var entity = _find(result.data, function(e) { return e.id === entityId; }); + var entity = _find(result.data, function(e) { return e.id === entityID; }); if (entity) { map.zoomTo(entity); } }); } map.on('drawn.zoomToEntity', function() { - if (!context.hasEntity(entityId)) return; + if (!context.hasEntity(entityID)) return; map.on('drawn.zoomToEntity', null); context.on('enter.zoomToEntity', null); - context.enter(modeSelect(context, [entityId])); + context.enter(modeSelect(context, [entityID])); }); context.on('enter.zoomToEntity', function() { diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 1118488b7..097a17665 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -483,7 +483,7 @@ export function rendererMap(context) { // OSM if (map.editable()) { - context.loadTiles(projection, dimensions); + context.loadTiles(projection); drawVector(difference, extent); } else { editOff(); diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index 0f664ffe4..866a9778e 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -19,10 +19,8 @@ import rbush from 'rbush'; import { geoExtent } from '../geo'; import { svgDefs } from '../svg'; -import { utilDetect } from '../util/detect'; import { utilQsString, utilRebind, utilTiler } from '../util'; -var tiler = utilTiler().skipNullIsland(true); var apibase = 'https://a.mapillary.com/v3/'; var viewercss = 'mapillary-js/mapillary.min.css'; @@ -30,6 +28,7 @@ var viewerjs = 'mapillary-js/mapillary.min.js'; var clientId = 'NzNRM2otQkR2SHJzaXJmNmdQWVQ0dzo1ZWYyMmYwNjdmNDdlNmVi'; var maxResults = 1000; var tileZoom = 14; +var tiler = utilTiler().skipNullIsland(true); var dispatch = d3_dispatch('loadedImages', 'loadedSigns'); var _mlyFallback = false; var _mlyCache; @@ -56,9 +55,7 @@ function maxPageAtZoom(z) { function loadTiles(which, url, projection) { var s = projection.scale() * 2 * Math.PI; var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); - - var dimension = projection.clipExtent()[1]; - var tiles = tiler.getTiles(projection, dimension, tileZoom); + var tiles = tiler.getTiles(projection, tileZoom); // abort inflight requests that are no longer needed var cache = _mlyCache[which]; diff --git a/modules/services/openstreetcam.js b/modules/services/openstreetcam.js index 6094be376..8fa1574e7 100644 --- a/modules/services/openstreetcam.js +++ b/modules/services/openstreetcam.js @@ -32,11 +32,11 @@ import { utilSetTransform } from '../util'; -var tiler = utilTiler().skipNullIsland(true); var apibase = 'https://openstreetcam.org'; var maxResults = 1000; var tileZoom = 14; +var tiler = utilTiler().skipNullIsland(true); var dispatch = d3_dispatch('loadedImages'); var imgZoom = d3_zoom() .extent([[0, 0], [320, 240]]) @@ -65,9 +65,7 @@ function maxPageAtZoom(z) { function loadTiles(which, url, projection) { var s = projection.scale() * 2 * Math.PI; var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); - - var dimension = projection.clipExtent()[1]; - var tiles = tiler.getTiles(projection, dimension, tileZoom); + var tiles = tiler.getTiles(projection, tileZoom); // abort inflight requests that are no longer needed var cache = _oscCache[which]; @@ -123,8 +121,8 @@ function loadNextTilePage(which, currZoom, url, tile) { } var features = data.currentPageItems.map(function(item) { - var loc = [+item.lng, +item.lat], - d; + var loc = [+item.lng, +item.lat]; + var d; if (which === 'images') { d = { @@ -172,14 +170,14 @@ function loadNextTilePage(which, currZoom, url, tile) { function partitionViewport(psize, projection) { var dimensions = projection.clipExtent()[1]; psize = psize || 16; - var cols = d3_range(0, dimensions[0], psize), - rows = d3_range(0, dimensions[1], psize), - partitions = []; + var cols = d3_range(0, dimensions[0], psize); + var rows = d3_range(0, dimensions[1], psize); + var partitions = []; rows.forEach(function(y) { cols.forEach(function(x) { - var min = [x, y + psize], - max = [x + psize, y]; + var min = [x, y + psize]; + var max = [x + psize, y]; partitions.push( geoExtent(projection.invert(min), projection.invert(max))); }); diff --git a/modules/services/osm.js b/modules/services/osm.js index d5a812b80..fe02d626d 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -33,8 +33,8 @@ import { utilQsString } from '../util'; -var tiler = utilTiler(); +var tiler = utilTiler(); var dispatch = d3_dispatch('authLoading', 'authDone', 'change', 'loading', 'loaded', 'loadedNotes'); var urlroot = 'https://www.openstreetmap.org'; var oauth = osmAuth({ @@ -752,7 +752,7 @@ export default { // Load data (entities or notes) from the API in tiles // GET /api/0.6/map?bbox= // GET /api/0.6/notes?bbox= - loadTiles: function(projection, dimensions, callback, noteOptions) { + loadTiles: function(projection, callback, noteOptions) { if (_off) return; var that = this; @@ -778,7 +778,7 @@ export default { } // determine the needed tiles to cover the view - var tiles = tiler.getTiles(projection, dimensions, tilezoom); + var tiles = tiler.getTiles(projection, tilezoom); // abort inflight requests that are no longer needed var hadRequests = !_isEmpty(cache.inflight); @@ -831,9 +831,9 @@ export default { // Load notes from the API (just calls this.loadTiles) // GET /api/0.6/notes?bbox= - loadNotes: function(projection, dimensions, noteOptions) { + loadNotes: function(projection, noteOptions) { noteOptions = _extend({ limit: 10000, closed: 7}, noteOptions); - this.loadTiles(projection, dimensions, null, noteOptions); + this.loadTiles(projection, null, noteOptions); }, diff --git a/modules/services/streetside.js b/modules/services/streetside.js index f028e11b3..ea9971f2d 100644 --- a/modules/services/streetside.js +++ b/modules/services/streetside.js @@ -33,7 +33,6 @@ import { utilQsString, utilRebind, utilTiler } from '../util'; import Q from 'q'; -var tiler = utilTiler().skipNullIsland(true); var bubbleApi = 'https://dev.virtualearth.net/mapcontrol/HumanScaleServices/GetBubbles.ashx?'; var streetsideImagesApi = 'https://t.ssl.ak.tiles.virtualearth.net/tiles/'; @@ -42,10 +41,12 @@ var pannellumViewerCSS = 'pannellum-streetside/pannellum.css'; var pannellumViewerJS = 'pannellum-streetside/pannellum.js'; var maxResults = 2000; var tileZoom = 16.5; +var tiler = utilTiler().skipNullIsland(true); var dispatch = d3_dispatch('loadedBubbles', 'viewerChanged'); var minHfov = 10; // zoom in degrees: 20, 10, 5 var maxHfov = 90; // zoom out degrees var defaultHfov = 45; + var _hires = false; var _resolution = 512; // higher numbers are slower - 512, 1024, 2048, 4096 var _currScene = 0; @@ -82,11 +83,7 @@ function localeTimestamp(s) { function loadTiles(which, url, projection, margin) { var s = projection.scale() * 2 * Math.PI; var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); - - var dimension = projection.clipExtent()[1]; - var tiles = tiler - .margin(margin) - .getTiles(projection, dimension, tileZoom); + var tiles = tiler.margin(margin).getTiles(projection, tileZoom); // abort inflight requests that are no longer needed var cache = _ssCache[which]; diff --git a/modules/util/tiler.js b/modules/util/tiler.js index d66e29933..a869a3472 100644 --- a/modules/util/tiler.js +++ b/modules/util/tiler.js @@ -76,7 +76,8 @@ export function utilTiler() { * Using d3.geo.tiles.js from lib, gets tile extents for each grid tile in a grid created from * an area around (and including) the current map view extents. */ - tiler.getTiles = function(projection, dimensions, tilezoom) { + tiler.getTiles = function(projection, tilezoom) { + var dimensions = projection.clipExtent()[1]; var s = projection.scale() * 2 * Math.PI; var z = Math.max(Math.log(s) / Math.log(2) - 8, 0); var ts = 256 * Math.pow(2, z - tilezoom);