Maximizing OpenLayers v3 Performance on an Old Browser

I have an application where I use React to render an OpenLayers map (using version 3) in order to display a .mbtiles file served from Tilserver-gl-light. The app functions and does what I want it to, but it will be running on an old browser that is not very powerful. When I run the app in my dev environment (latest version of Chrome), it works well. I am looking for any other optimizations that you may recommend for me to try.

MapComponent.jsx:

import React, { useEffect, useState, useRef } from 'react'
import ol from 'openlayers'

import InfoCard from './InfoCard/InfoCard'


const center = [-9735948.897, 3526370.974, -9695948.897, 3566370.974]





const MapComponent = () => {
    const [error, setError] = useState(null)
    const [infoCardOpen, setInfoCardOpen] = useState(false)
    const [infoCardInfo, setInfoCardInfo] = useState(null)


    const styleFunction = (feature) => {
        const layerName = feature.get('layer');
  
        if (layerName === 'DEPARE' || layerName === "SLCONS" || layerName === "FAIRWY" || layerName === "NAVAIDS"){
            return null
        }

        return new ol.style.Style({
            stroke: new ol.style.Stroke({
              color: 'black',
              width: 1,
            }),
          });
      };

    
      const vectorTileSource = new ol.source.VectorTile({
        format: new ol.format.MVT(),
        tileGrid: new ol.tilegrid.createXYZ(),
        buffer: 1,
        tilePixelRatio: 14,
        url: `http://${location.host}:8080/data/my_tiles/{z}/{x}/{y}.pbf`,
    })


    const vectorTileLayer = new ol.layer.VectorTile({
        preload: Infinity,
        source: vectorTileSource,
        style: styleFunction,
        renderBuffer: 512,
        updateWhileAnimating: false,
        updateWhileInteracting: false,
        renderMode: 'hybrid'
    })

    useEffect(() => {
        try{
            const controls = ol.control.defaults({
                attributionOptions: ({
                  collapsible: false
                })
              }).extend([
                new ol.control.ZoomToExtent({
                  extent: [center]
                })
              ])
        
            const view = new ol.View({
                center: PensacolaFlorida,
                zoom: 12,
                projection: 'EPSG:3857',
            })

            
            
            const map = new ol.Map({
                cacheSize: 2000,
                layers: [
                    vectorTileLayer
                ],
                controls: controls,
                target: 'map',
                view: view,
                loadTilesWhileInteracting: true,
                loadTilesWhileAnimating: true
            })
            
            

            map.on('movestart', () => {
                vectorTileLayer.setExtent(map.getView().calculateExtent())
            });
            
            map.on('moveend', () => {
                vectorTileLayer.setExtent(undefined)
            });

            map.on('click', (event) => {
                map.forEachFeatureAtPixel(event.pixel, (feature, layer) => {
                    const properties = feature.getProperties();
                    displayFeatureInfo(properties);
                    return true;
                  });
            })

            const displayFeatureInfo = (properties) => {
                setInfoCardOpen(true)
                setInfoCardInfo(properties)
                console.log(properties)
                setTimeout(() => {
                    setInfoCardOpen(false)
                }, 3000)
            }
              
            return () => {
                map.setTarget(null)
            }
        } catch(err){
            const errorMessage = `Error initializing map: ${err.message}`;
        }
    }, [])

    
    return (
        <div className='map-container'>
            {error ? <h1>{error}</h1> : <div id='map'></div>}
            {infoCardOpen && <InfoCard info={infoCardInfo}/>}
        </div>
    )
}

export default MapComponent

I have utilized various different approaches, some of which did indeed help. Those that have helped so far: excluding certain feature layers using a style function, map.on('movestart' || 'moveend') functionality, loadTilesWhileInteracting and loadTilesWhileAnimating.

Something I wanted to do was use OpenLayers’ Cluster, but this does not work for VectorTiles to my knowledge. I also heard about OffscreenCanvas which sounds incredible, but this is not supported on the browser the app will run on.

Please let me know any other optimizations to increase the pan/zoom/rotate speed of the map if any come to mind.

Thanks,
Wade

New contributor

wade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật