mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 12:19:31 +02:00
switch to Bing Maps API for Bing Streetside layer, fixes #10074
replaces the use of undocumented APIs for Microsoft's street level imagery service and gets rid of hardcoded values, e.g. for the `g` ("generation") parameter
see https://learn.microsoft.com/en-us/bingmaps/rest-services/imagery/get-imagery-metadata#get-streetside-metadata-centered-at-a-point for API docs
see also #10100
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
|
||||
var jsonpCache = {};
|
||||
window.jsonpCache = jsonpCache;
|
||||
|
||||
export function jsonpRequest(url, callback) {
|
||||
var request = {
|
||||
abort: function() {}
|
||||
};
|
||||
|
||||
if (window.JSONP_FIX) {
|
||||
if (window.JSONP_DELAY === 0) {
|
||||
callback(window.JSONP_FIX);
|
||||
} else {
|
||||
var t = window.setTimeout(function() {
|
||||
callback(window.JSONP_FIX);
|
||||
}, window.JSONP_DELAY || 0);
|
||||
|
||||
request.abort = function() { window.clearTimeout(t); };
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
function rand() {
|
||||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
var c = '';
|
||||
var i = -1;
|
||||
while (++i < 15) c += chars.charAt(Math.floor(Math.random() * 52));
|
||||
return c;
|
||||
}
|
||||
|
||||
function create(url) {
|
||||
var e = url.match(/callback=(\w+)/);
|
||||
var c = e ? e[1] : rand();
|
||||
|
||||
jsonpCache[c] = function(data) {
|
||||
if (jsonpCache[c]) {
|
||||
callback(data);
|
||||
}
|
||||
finalize();
|
||||
};
|
||||
|
||||
function finalize() {
|
||||
delete jsonpCache[c];
|
||||
script.remove();
|
||||
}
|
||||
|
||||
request.abort = finalize;
|
||||
return 'jsonpCache.' + c;
|
||||
}
|
||||
|
||||
var cb = create(url);
|
||||
|
||||
var script = d3_select('head')
|
||||
.append('script')
|
||||
.attr('type', 'text/javascript')
|
||||
.attr('src', url.replace(/(\{|%7B)callback(\}|%7D)/, cb));
|
||||
|
||||
return request;
|
||||
}
|
||||
Reference in New Issue
Block a user