Atlaslog
Atlaslog / Leaflet / API reference / GeoJSON Options
Leaflet · API reference

GeoJSON Options

Quick answer

The GeoJSON options object controls how L.geoJSON converts data: pointToLayer chooses point classes, filter drops features early, style shapes lines and polygons, and onEachFeature attaches popups and listeners. Path styling values such as color, weight and fillOpacity pass straight through to lines and polygons. Tuning these callbacks avoids post-processing loops over generated layers.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.geoJSON( geojson , options ) → GeoJSON
Key points
Example
L.geoJSON(data, {
  filter: function (feature) {
    return feature.properties.type !== 'hidden';
  },

  style: function (feature) {
    var level = feature.properties.level;
    return {
      color: level > 2 ? '#c2410c' : '#1f5fd0',
      weight: 1 + level * 0.6,
      fillOpacity: 0.1 + level * 0.05
    };
  },

  pointToLayer: function (feature, latlng) {
    return L.circleMarker(latlng, {
      radius: 5,
      color: '#fff',
      weight: 1,
      fillColor: '#17694a',
      fillOpacity: 0.9
    });
  },

  onEachFeature: function (feature, layer) {
    if (!feature.properties.name) return;
    layer.bindTooltip(feature.properties.name, { direction: 'top' });
  }
}).addTo(map);
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). GeoJSON Options. https://www.jingweizhi.com/en/leaflet/api/geojson-options.html (accessed 2026-11-03).