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

Problem with callbacks #18

Open
ShammyLevva opened this issue Jun 26, 2023 · 0 comments
Open

Problem with callbacks #18

ShammyLevva opened this issue Jun 26, 2023 · 0 comments

Comments

@ShammyLevva
Copy link

Hi there,

I'm getting a odd problem with callbacks that more often than not don't work. If I disable caching and empty cache and force a refresh it will occassionally work which is very frustraing that it's not 100% repeatable. The vast majority of the time though this error is thrown. It's as if it hasn't picked up the definition of getJson before it's used. As I say incognito or forcing clearing cache does seem to work occassionaly then I make a change deploy again and get error back.

I'm using Leaflet 1.9.4 and JQuery 3.5.1.

my code is:

surveyDates = L.Geoserver.wfs("https://maps.redacted-server-name-here.com/geoserver/wfs", {
    layers: "poa:SurveyDates",
    onEachFeature: function (feature, layer) {
        if (feature.properties?.name && feature.properties?.lastSurvey) {
            let survey = " last surveyed: " + new Date(feature.properties.lastSurvey);
            layer.bindTooltip(feature.properties.name + survey);
        }
        if (feature.properties.surveyType == 1) {
            layer.setStyle({ fillColor: '#dc4405' });
        } else {
            layer.setStyle({ fillColor: '#477A7B' });
        }
    }
});

Error is:

Object 'parsererror' Error: getJson was not called
at Function.error (jquery.js:334:9)
at s.converters.script json (jquery.js:10232:12)
at ajaxConvert (jquery.js:9260:19)
at done (jquery.js:9736:15)
at HTMLScriptElement.callback (jquery.js:10170:8)
at HTMLScriptElement.dispatch (jquery.js:5429:27)
at elemData.handle (jquery.js:5233:28)
wfs?callback=getJson&service=WFS&version=1.1.0&request=GetFeature&typename=poa%3ASurveyDates&CQL_FILTER=INCLUDE&srsname=EPSG%3A4326&outputFormat=text%2Fjavascript&format_options=callback%3A%20getJson&=1687773981153:1 Uncaught ReferenceError: getJson is not defined
at wfs?callback=getJson&service=WFS&version=1.1.0&request=GetFeature&typename=poa%3ASurveyDates&CQL_FILTER=INCLUDE&srsname=EPSG%3A4326&outputFormat=text%2Fjavascript&format_options=callback%3A%20getJson&
=1687773981153:1:2
(anonymous) @ wfs?callback=getJson&service=WFS&version=1.1.0&request=GetFeature&typename=poa%3ASurveyDates&CQL_FILTER=INCLUDE&srsname=EPSG%3A4326&outputFormat=text%2Fjavascript&format_options=callback%3A%20getJson&_=1687773981153:1

In case it's relevant I'm also seeing this error

L.Geoserver.js:106 Uncaught TypeError: Cannot read properties of undefined (reading 'fitBounds')
at Object.success (L.Geoserver.js:106:31)
at fire (jquery.js:3496:31)
at Object.fireWith [as resolveWith] (jquery.js:3626:7)
at done (jquery.js:9786:14)
at HTMLScriptElement.callback (jquery.js:10170:8)
at HTMLScriptElement.dispatch (jquery.js:5429:27)
at elemData.handle (jquery.js:5233:28)

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