0

I have some GeoJSON data layers which I fetch their features from phpMyAdmin to display on a Leaflet map.

But loading the features takes almost 10 seconds to be loaded.

Have you any solution to speed up the loading process?

My data layer has a multipolygon type which covered data for boundary of Turkey provinces. accordingly each item has a long vertex info. i load them as text (1000000) and then convert by ST_GeomFromText(WKT,26913) to geometry.

I use the folowing code to add that to map:

       var Layer1 = L.layerGroup();
        
        // Fetch the GeoJSON data from the PHP file
        fetch('Layer1 .php')
            .then(response => response.json())
            .then(data => {
                L.geoJSON(data, {
                    style: function (feature) {
                        return {
                            stroke: true,
                            color: '#980043',
                            weight: 2,
                            fillOpacity: 0.3                            
                         };
                    },
                onEachFeature: function (feature, layer) {
                    var popupContent = "<b> some text" ;
                    
                    layer.bindTooltip(popupContent, { sticky: true });
                }
                }).addTo(Layer1); 
            });
        Layer1 .addTo(map);

Additionally, can I add a progress bar that display data loading process of layers to map?

6
  • 1
    Simplest solution would be to zip GeoJSON data on the server side and unzip it on the client side.
    – TomazicM
    Dec 5, 2023 at 15:57
  • 1
    This needs some perf measuremets: the bottleneck might be either in the client (JS) or the webserver (PHP). How much time does the browser take to load, and how much to process? Dec 5, 2023 at 16:23
  • Simplify? And store a binary format rather than geojson
    – Ian Turton
    Dec 5, 2023 at 16:26
  • Maybe changing your overall concept and switching to WMS / WFS / Vector Tiles Dec 5, 2023 at 19:18
  • could you give some more detail on this methods? where can i found related documantation or any examples?
    – Solmaz
    Dec 6, 2023 at 7:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.