digidem / leaflet-bing-layer

Bing Maps Layer for Leaflet v1.0.0
http://digidem.github.io/leaflet-bing-layer/
88 stars 55 forks source link

Live example not working #58

Open egiorgioPatagonian opened 1 month ago

egiorgioPatagonian commented 1 month ago

Hi! I detected a problem when data from bing comming. Sometimes there are token some times no and the funcion utils try to replace but there no value there. The problem is Utils.js.

Example: "imageUrl": "http://ecn.{subdomain}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=14715&mkt={culture}&shading=hill", OR "imageUrl": "http://{subdomain}.tiles.virtualearth.net/tiles/r{quadkey}.jpeg?g=14715&mkt={culture}&shading=hill&token={token}",

image image

egiorgioPatagonian commented 1 month ago

I know this is not a solution but It is alternative if you need to fix quick menwhile It is working on the problem L.Util.template = function (str, data) { return str.replace(/{ ([\w_]+) }/g, function (str, key) { var value = data[key];

        // Special handling for 'token'
        if (key === 'token') {
            if (value === undefined) {
                // If no value is provided for 'token', leave the placeholder {token} in the string
                return str;
            }
        }

        // Throw an error for other variables if they are undefined
        if (value === undefined) {
            throw new Error('No value provided for variable ' + str);
        }

        // If the value is a function, call it and pass in 'data'
        if (typeof value === 'function') {
            value = value(data);
        }

        return value;
    });
};