netzmacht / contao-leaflet-maps

Leaflet maps extension for Contao CMS
12 stars 8 forks source link

Working installation on Contao 4.13.15 not possible? #122

Closed Shoekrates closed 1 year ago

Shoekrates commented 1 year ago

Hi, I tried to install Leaflet Maps on Contao 4.13.15 with no real success to make the extension working. My system: Contao 4.13.15, PHP 8.0.28, Contao Manager 1.6.2 in use, no ssh access.

Here are the steps taken: Installation of https://github.com/netzmacht/contao-leaflet-maps using the Contao Manager. After the installation (last step composer install, no errors in console view) follows no database update step. The left database update button is disabled. I can only click the right button to close the installation. Afterwards the Contao system in frontend and backend immediately gets the standard contao error – nothin works anymore.

The error from /var/log/ is this: ArrayIterator::__construct(): Argument #1 ($array) must be of type array, null given" at /FOLDER/vendor/netzmacht/contao-leaflet-maps/src/Frontend/Assets/LibrariesConfiguration.php line 52

In the manager's maintenance section a database error can be found, but opening the install tool leads to the same contao error as mentioned above. Following the issue https://github.com/netzmacht/contao-leaflet-maps/issues/121 (sorry, I am no php expert) I somehow fixed it with adding $GLOBALS['LEAFLET_LIBRARIES'] = []; to the file /netzmacht/contao-leaflet-maps/src/Frontend/Assets/LibrariesConfiguration.php on line 50:

public function getIterator()
    {
        $GLOBALS['LEAFLET_LIBRARIES'] = [];
        $this->framework->initialize();
        return new \ArrayIterator($GLOBALS['LEAFLET_LIBRARIES']);
    }

(Again – sorry, I am no php expert!)

With this I can open the frontend and the backend again and I can proceed with the installation. With the install tool I can add the necessary database tables. Afterwards I can use leaflet in the backend of Contao. But when I try to add a new marker layer (map layer preconfigured with OSM/Mapnik already added) I see no map in the interface: grafik Even adding Coordinates does not work. The map does not show up nor in the backend or in the frontend with a corresponding module. I don't know if this is just due to my line adding in LibrariesConfiguration.php (see above). When I delete this line the contao error comes back.

I installed https://github.com/netzmacht/contao-leaflet-libraries as well. Same problem. I changed installation ordner, at first the libraries, then the maps extension. Same problem. I deleted the prod and dev cache folders after installation according to https://github.com/netzmacht/contao-leaflet-maps/issues/96, same problem.

How can I make it work and use the extension in my installation? Any help appreciated. Edit: formatting improvements

Shoekrates commented 1 year ago

Okay, sometimes you only need to write your problem down and think about it ... I just saw a javascript error in the console in the backend marker screen view stating that there is a mimetype mismatch leading to not loading some files from /assets/leaflet/libs.... Checking the files I discovered that there wasn't any folder /assets/leaflet/... ?! I copied over the folders from /vendor/netzmacht/contao-leaflet-libraries/assets/ to /assets/leaflet/libs/ and after that I see a map in the backend and searching a location works:

grafik

So I think there is something wrong in the installation process of the extension? This fix only solves my backend problem, not the installation problem.

I am going to proceed now and try to add my location map to the website. I am going to report if I have success.

Shoekrates commented 1 year ago

Okay, I am running into some more problems. Adding a leaflet map to the frontend through the content element after defining a map does not load the necessary javascripts. This produces the console error Uncaught ReferenceError: L is not defined

If I add leaflet.js and leaflet-providers.min.js manually to the head of the website some map tiles get loaded but there are follow up javascript errors. So I guess that there is some misconfiguration happening already in the installation process. How can we fix it?

dmolineus commented 1 year ago

Should be fixed by a2d1ae683df369e862ae44ba6f5e32a894914ce8.

Shoekrates commented 1 year ago

Just wanted to give feedback that installation now works as expected with your fix. So far everything works fine! Thank you very much!

igi-1w3r53n commented 1 year ago

I have exactly the same problem (Cotnao 4.13.24 + Leaflet 3.2.4). Your fix @Shoekrates helped me to show the map in the backend but the frontend still comes with the "Uncaught ReferenceError: L is not defined" error.

The fix in a2d1ae6 from @dmolineus did not help because my file already looks this way. Is there any other idea how this could be fixed (dirty workarounds are welcome as well...)?