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

background layers don't initialise and geolocationbehavior lat/long fields and marker on map sometimes disconnect #17

Open
fredvd opened this issue Mar 24, 2022 · 2 comments

Comments

@fredvd
Copy link

fredvd commented Mar 24, 2022

@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)
  1. 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)

  1. 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.

spinner

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)

https://github.com/plone/plone.patternslib/blob/061473c1026f1a3a01d27c4ea5d33c9095b054fd/src/plone/patternslib/static/components/leaflet.markercluster/src/MarkerClusterGroup.js#L863

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.

@fredvd fredvd mentioned this issue Mar 24, 2022
44 tasks
@petschki
Copy link
Member

Maybe fixed here Leaflet/Leaflet.markercluster#635 ... updating leaflet.js might solve some problems here ...

@petschki
Copy link
Member

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

2 participants