Description
@thet @petschki A discussed yesterday on discord I'm posting this issue on the pat-leaflet repo, but I'm not sure yet technically how/if the code here is used in Plone 5.2 / Plone 6.
So have set up some content to use the geolocationbehavior on a Plone 5.2.7 Python3.8.12 setup.
The packages involved are:
- collective.geolocationbehavior (1.7.2)
- plone.formwidget.geolocation (z3c.form integration) (2.2.4.dev0 default_location branch)
- plone.patternslib (pat-leaflet for Plone < 6) (1.2.2.dev0 main/master branch)
- The first issue I noticed is that the map didn't initialise the background or location until I used a control to jump to my current location. I solved this with specifying coordinates in the control panel, but these were then also used as default values and I found @laulaz branch that fixes this double role (Default location collective/plone.formwidget.geolocation#32)
With correct lat/long values the leaflet map initalises correctly in the center of the country/website for which my setup is needed.
(There's another minor issue here: the control panel fields give a decimal error when you try to use more than 3 digits behind the . or , I suspect a dot/comma internationaliastion issue here. The lat/long fields in the behavoir doen't have this problem)
- The second issue is that sometimes the red marker that connects to the lat/long fields below the map sometimes disappers when you try to inser a location. This for example happens when using the built-in and default configure street address lookup. Most of the time when a valid location is found the map jumps to that address and the marker is reposiioned there. And you can then drag the marker and see the lag/long update. The address seek control shows a spinner in it's icon that doesn stop, you are moved to the location (Brussels, Amsterdam) but the red marker is gone.
When I add the add'ons above to a clean Plone 5.2.8.dev0 coredev buidout and set the resources to develop and I develop the pat-leaflet bundlle I can see a traceback at exactly this line (well the developer tools report the line in the MarkerCluster-src.js bundle)
I think it tries to adapt the zoomlevel but in some instances the parent object doesn't exist, so you see
ncaught TypeError: parent is undefined
_addLayer http://localhost:8080/Plone/++plone++patternslib/components/leaflet.markercluster/dist/leaflet.markercluster-src.js:868
addLayer http://localhost:8080/Plone/++plone++patternslib/components/leaflet.markercluster/dist/leaflet.markercluster-src.js:111
initUndefined http://localhost:8080/Plone/++plone++patternslib/components/pat-leaflet/src/pat-leaflet.js:222
fireEvent http://localhost:8080/Plone/++plone++patternslib/components/leaflet/dist/leaflet-src.js:461
_showLocation http://localhost:8080/Plone/++plone++patternslib/components/L.GeoSearch/src/js/l.control.geosearch.js:236
_processResults http://localhost:8080/Plone/++plone++patternslib/components/L.GeoSearch/src/js/l.control.geosearch.js:201
onreadystatechange http://localhost:8080/Plone/++plone++patternslib/components/L.GeoSearch/src/js/l.control.geosearch.js:165
I do suspect some timing/race condition as the error seems more difficult to trigger when in development mode.