geonotebook
geonotebook copied to clipboard
Geonotebook map doesn't render if point annotation is added programmatically.
I am currently adding a point annotation to the map programmatically and it does not appear. I can use the following command to see if the point was created "M.layers.annotation.points" and it is listed on the map. I can clear the point from the map and create it again, but I can never see it. If I create the point and refresh the page, the map loads again with the point visible on the map and listed, but then it cannot be removed and any other annotation added cannot be removed as well. Only by going to kernel and choosing to "restart & clear output" will the annotations disappear. I will include a few steps and 2 images.
Steps: 1.Adding annotation point to the map programmatically 2.Reload page without deleting the point 3.Point appears on the map. Deleting the point does not make it disappear from the map or list.
Here is a snippet of the issue before reloading the page.
Here is a snippet of the issue after refreshing the page.
Thanks for reporting @Gustavohernandez1
I believe this issue is related: https://github.com/OpenGeoscience/geonotebook/issues/97
To expand on the issue, there is a problem with the RPC messages when reloading the page. Some calls made from the client after a refresh have an invalid comm id. I have reproduced this with both the geojs and openlayers renderers. @kotfic is probably the most knowledgeable in this area.
@Gustavohernandez1 while @jbeezley is right that there are some issues with refreshing and comm stuff, this actually looks like a much more simple problem.
Currently you are calling M.layers.annotation.add_annotation
and you should be calling M.add_annotation
- I'm sorry the documentation wasn't more clear on this!
M.add_annotation
is the RPC function that add's an annotation to the javascript map, once the annotation has been successfully added the javascript function returns and the python callback function M.layers.annotation.add_annotation
is called. When you call M.layers.annotation.add_annotation
on the server side this adds the annotation server side, but not client side. When you refresh that state is communicated down to the client side and the point that was not visible before appears.
The fact that the annotation doesn't clear after refresh is however a bug, I will see if i can track down why that is happening.
Either way, I will put together a small PR that converts M.layers.annotation.add_annotation
to M.layers.annotation._add_annotation
so it is a little more clear that the callback function should not used.