Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live example not working #58

Open
egiorgioPatagonian opened this issue Sep 27, 2024 · 1 comment
Open

Live example not working #58

egiorgioPatagonian opened this issue Sep 27, 2024 · 1 comment

Comments

@egiorgioPatagonian
Copy link

egiorgioPatagonian commented Sep 27, 2024

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
Copy link
Author

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;
    });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant