mapboxgl.js versus leaflet.js

2019-05-29 02:33发布

问题:

I am about to start a web application with the main purpose of displaying a mapbox map, toggle layers and display data based on interactions with the map.

I'm wondering should I be using mapboxgl.js AND leaflet.js, mapboxgl.js OR leaflet.js. Everyone keeps saying leaflet is amazing but wondering if mapboxgl gives you the same functionality and performance? I keep reading conflicting things on the internet

Would really appreciate the help

回答1:

A few words to clarify the difference:

  • mapboxgl uses browsers' WebGL technology, therefore it requires a modern enough browser, and uses more client computing power. The advantage is that it can natively handle vector tiles and render them any way you like (rotation, tilt, perspective like for a GPS navigation device, custom style, etc.)
  • Leaflet uses plain DOM manipulation, and is designed to (theoretically) support old browsers like IE8. It is very efficient for such old browsers, and also mobile-friendly due to this lightweight computing footprint. The advantage is that it enables you including a basic map without too much overhead. Most basic usages can be covered with Leaflet, possibly with some plugins. The drawback is that it mainly supports raster tiles, so they must be rendered server-side (mapbox provides such service).