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
Cannot create more than one map on a page #154
Comments
Is this because of the singleton |
What is the error you are getting? No it won't be because of the vglViewerInstance. It would be because of the global var gl. |
I thin its a vgl specific issue. Will push a fix on Monday (or on plane today). But if someone wants to take a look at it, then have a look at the variable gl. Basically, we have to localize it for each instance. |
This must be the problem. Private variable GOOD, global variable BAD! :-P |
Right.. unlike desktop gl, the webgl required making calls via this variable which complicated things just b bit. I think there two ways to handle this. We can enclose all the global vars if there are any into their own space (like what we do in jquery plugin) or pass the var to the gl objects. I am wondering what folks things about it |
by enclosing globals, we will turn them into locals, so no globals. |
I'm not sure what you mean about enclosing globals, but it seems to me that there should be a GL context either for each map object, or each GL layer. That way when draw calls are made within a [map | layer], the GL context local to that [map | layer] could be invoked directly. |
The singleton On a related point, we have a private |
Yeah, just from a software engineering standpoint, anything that is attached to a map should probably not be global or a singleton. "Viewers" and "contexts" seem like resources associated to one instance of a map, and as such should be created afresh and held privately by the map objects as needed. |
I would prefer not to expose init and exit ... at least at the layer or below level. The idea is that parent container will do that for the child one. |
Yes, but who does it for |
Two things... In my comment above that's why I said layer or below. I think when the map goes away js should garbage collect other objects. I have not seen any map API that has public exit method and that' why I would like to avoid it |
That is reasonable, but we need to make sure there are no globals hanging around preventing the garbage collection from occurring. |
@aashish24 Have you looked into this at all? It is causing problems in the GRITS application, and I'm not sure I am qualified to fix it. |
I did some but didn't work on it much. I didn't realize its causing issues. I will look into this week and will try to get it done asap. |
Awesome! Thanks @aashish24. |
In the following example, only the map on the right displays, while it responds to mouse events over both
#map1
and#map2
. There are similar issues with creating map, deleting the map, and creating a new map. The events from the deleted map are still being propagated in the new map. It seems like there are some properties in the gl renderer that are being shared globally. I'm not sure the extent to which it is possible to have two gl contexts on the same page, but at least we should make it possible to remove one cleanly and create another.The text was updated successfully, but these errors were encountered: