obj is undefined when trying to call FromLatLngToPoint on projection in OnAfterMapInit()
cruiserkernan opened this issue · 1 comments
cruiserkernan commented
Description
Encountering a TypeError
in the browser console when attempting to call FromLatLngToPoint
on a projection object in the OnAfterMapInit()
method. The error suggests that obj
is undefined in objectManager.js
in the context of this function call.
Reproduction Code
private async Task OnAfterMapInit()
{
var projection = await map1.InteropObject.GetProjection();
var testPointFromLatLng = await projection.FromLatLngToPoint(new LatLngLiteral()
{
Lat = 59.612529,
Lng = 16.567550
});
if (testPointFromLatLng is null)
{
// This should not happen
}
}
Console Error
TypeError: Cannot read properties of undefined (reading 'fromLatLngToPoint')
at Object.invoke (objectManager.js:536:40)
at blazor.server.js:1:3501
...
Source Code Context
In the source code, the error occurs at:
else if (functionToInvoke == "fromLatLngToPoint") {
try {
var point = obj[functionToInvoke](args2[0]);
return point;
} catch (e) {
console.log(e);
}
}
Additional Observations
- The issue does not occur when bypassing the GoogleMap component and creating a map manually using a div element.
Expected Behavior
The method FromLatLngToPoint
should be called without any errors, and obj
in objectManager.js
should not be undefined
.
valentasm1 commented
If you add some delay it all works. I assume it is just need some timeout to load smth.